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

include_external_user_ids must be an array of non empty strings #131

Closed
mreduar opened this issue Apr 16, 2021 · 2 comments
Closed

include_external_user_ids must be an array of non empty strings #131

mreduar opened this issue Apr 16, 2021 · 2 comments

Comments

@mreduar
Copy link

mreduar commented Apr 16, 2021

I am repeatedly experiencing this error. It is the response OneSignal gives when making the POST request to send the notification.

GuzzleHttp\Exception\ClientException
Client error: `POST https://onesignal.com/api/v1/notifications` resulted in a `400 Bad Request` response:
{"errors":["include_external_user_ids must be an array of non empty strings"]}

I guess it is because an empty array is being passed to include_external_user_ids in the line 37 of OneSignalPayloadFactory

However these ids come directly from the routeNotificationForOneSignal method in the User model. Which is declared as follows

    /**
     * Route notifications for the OneSignal channel.
     *
     * @ @param \IlluminateNotifications $notification
     * @return string
     */
    public function routeNotificationForOneSignal($notification)
    {
        return ['include_external_user_ids' => $this->id];
    }

The id of my database in the users table cannot be null. Therefore I deduce that if this array is being filled with the id of the user.

This is what the payload looks like just before it is sent by the Berkayk\OneSignal package
image

I am using

"laravel-notification-channels/onesignal": "^2.1",
"laravel/framework": "^7.0",

This error has more than 5k occurrences in the last two days.
You can see a full report here.

Any suggestions on how to fix?

@AlexR1712
Copy link

AlexR1712 commented Apr 16, 2021

You need to make sure the include_external_user_ids property is a string and not a number

@mreduar
Copy link
Author

mreduar commented Apr 19, 2021

Thank you, this solves the problem. It seems that onesignal has updated the API to better validate this, as previously an array of integers was sufficient to send the notification. PR #132 clarifies the documentation.

@mreduar mreduar closed this as completed Apr 19, 2021
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

2 participants