Skip to content

include_external_user_ids must be an array of non empty strings #131

@mreduar

Description

@mreduar

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions