0

Im trying to send push with two criteria in where. I make this so:

curl -X POST 
-H "X-Parse-Application-Id: myappId" \
-H "X-Parse-REST-API-Key: myRESTApiId" \
-H "Content-Type: application/json" \
-d '{
"where": {“$and”:[{“deviceType": "winphone”},{”channels":{"$all":[“string1”],"$nin":[“string2”]}}]},
"data": {"alert": “String1 is comming”}
  }' \
https://api.parse.com/1/push

Something like: https://parse.com/questions/rest-api-or-constraint-on-multiple-fields-using-where, but I getting error message: error code 107 - invalid JSON Parse

How can I send push notification for given device and for given channel with condition $all and $nin.

Thanks for your help! Hipek

2
  • It would be useful if you explained what you are trying to do and how it is currently not working (e.g. what error messages you are getting). Commented Aug 31, 2015 at 23:26
  • I trying to send push notification via "curl" to windows phone device to people which are interested in "string1" and not interested in "string2". Commented Aug 31, 2015 at 23:34

1 Answer 1

2

This error is likely being returned because your where value does not match the REST API spec. You will also want to make sure you are consistent in your use of double quotes as these can also lead to malformed JSON errors (e.g. do not use and , use ").

After fixing that, we end up with the following, which is still not valid per the REST API Parse docs:

"where": {
  "$and": [ 
            {"deviceType": "winphone”},
            {"channels": { 
               "$all": ["string1"],
               "$nin":["string2"]}
              }
          ]
},

There's a couple of problems with your query:

  1. $and is not a valid Parse REST API operator, and does not appear in the REST API docs. All constraints in a where query are implicitly ANDed, so this is unnecessary, anyway.

  2. Your $all and $nin constraints over channels conflict with each other as there cannot be more than one such query per key. You may want to instead create a unique channel for those installations that should receive messages aimed at the string1 channel but not the string2 channel.

Sign up to request clarification or add additional context in comments.

2 Comments

I have simillar problem, I need to send a message only to people, who subscribe channel1 and dont subscribe channel2. Why is this request bad: {"deviceType": "winphone", "channels": {"$all": ["channel1"],"$nin":["channel2"]}, "data": { "alert":"channel1, but no channel2"} }? Also this request is bad: {"where": {{"deviceType": "winphone"},{"channels": {"$all": ["channel1"],"$nin":["channel2"]}}},"data": { "alert": "channel1, but no channel2"} }. Why is that so and what can I do to make it work properly?
The troubleshooting guide in the Parse documentation is a great place to start whenever you run into issues with push. One of the most important tips laid out there is to actually make sure your push query matches the installations you intend it to. If the push query does not accept $all and $nin on the same key, then your push simply won't have the intended audience.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.