Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client error: POST https://onesignal.com/api/v1/notifications resulted in a 400 Bad Request response: {"errors":["Segment user_id is not a valid filter field.","Segment device_id is not a valid filter field."]} #90

Open
ijazbhatti007 opened this issue Oct 8, 2018 · 4 comments

Comments

@ijazbhatti007
Copy link

ijazbhatti007 commented Oct 8, 2018

Client error: POST https://onesignal.com/api/v1/notifications resulted in a 400 Bad Request response: {"errors":["Segment user_id is not a valid filter field.","Segment device_id is not a valid filter field."]}
I am trying to send using tags

@samundra
Copy link
Contributor

samundra commented Oct 8, 2018

@ijazbhatti007

When you are making calls to send notification using the tags what library does is it translates your tags calls to filter calls which onesignal expects for tags.

The error you have likely could have been due to the incorrect payload and not because of the library itself. To have more information on the filters see onesignal's REST API documentation https://documentation.onesignal.com/reference#section-filter-usage

Also, Can you provide us the sample code block that you are using to send using tags?

That way we'll be able to help you more and guide further.

@rebirthtobi
Copy link

@ijazbhatti007 your array should be

array ( {"field": "tag", "key": "is_vip", "relation": "!=", "value": "true"} )

@samundra when sendNotificationUsingTags i think we don't need to specify the filed: tag again

@samundra
Copy link
Contributor

@ijazbhatti007 We have to be very specific and have to specify the field: tag ourselves.

If you look at https://github.com/berkayk/laravel-onesignal/blob/master/src/OneSignalClient.php#L182-L186 it simply adds anything that comes as $filters to filters key.

@gelinger777
Copy link

So right answer is

OneSignal::sendNotificationUsingTags(
           "Hi There, please check our new website update.",
           array(
               ["field"=>"tag","key" => "yourTagHere", "relation" => "=", "value" => "yourValueHere"]


              ),
           $url = 'https://google.com',
          $data = null,
          $buttons = null,
            $schedule = null
   );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants