Error 500: Array to string conversion

community

#1

Hi all,

I’m currently trying to use a Custom Scripting Service (written in V8js) in DreamFactory Silver 2.3.1-0 to post to an External HTTP Service called OneSignal (http://www.onesignal.com). I have used PostMan to successfully make a POST request to the OneSignal service which works without any issues.

However when I try to run the following code by in my Custom Service, I get an “Array to string conversion” error.

var onesignalObj = {
    "app_id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "include_player_ids" : ["xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxxxxx", "xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxxxxx"],
    "contents" : {"en":"content"}
    "headings" : {"en": "notification title"},
};

var onesignalResp = platform.api.post(
    "https://onesignal.com/api/v1/notifications",
    onesignalObj
);

If I simply provide an string value for the key “include_player_ids”, the POST will successfully reach the OneSignal API, but will return with an error as it is obviously expecting an array of strings. The error will appear regardless of if I call the OneSignal API directly from the Custom script or via a External HTTP Service setup in DSP.

Any help would be greatly appreciated.