Im tryin to use the http.request with a header parameter like below :
var headers = {};
headers["Authorization"] = "Basic KEY";
headers["Content-Type"] = "application/json";
var content = {};
content["en"] ='20 Free Coins when u click here!';
content["de"] ='20 DEFree Coins when u click here!';
var jsonBody = {
app_id: "APP ID",
included_segments: ["All"],
contents: content,
};
var link = "https://onesignal.com/api/v1/notifications";
log.info(JSON.stringify(jsonBody));
log.info(JSON.stringify(headers));
FriendList = http.request(link,"post", JSON.stringify(jsonBody), "text/plain", JSON.stringify(headers));
But i get following Error:
{
"code": 400,
"status": "BadRequest",
"error": "JavascriptException",
"errorCode": 1099,
"errorMessage": "Error: Exception has been thrown by the target of an invocation.\n at http.request (Script Document:2:86) -> nction(url, method, content, contentType, headers) { return playfab.http_reque\n at handlers.sendPush (main.js:97:21)\n at __playfab_internal.invokeHandler (Script Document:4:153)\ninfo : \"{\"app_id\":\"xyz\",\"included_segments\":[\"All\"],\"contents\":{\"en\":\"20 Free Coins when u click here!\",\"de\":\"20 DEFree Coins when u click here!\"}}\"\ninfo : \"{\"Authorization\":\"Basic xyz\",\"Content-Type\":\"application/json\"}\"\n\nScript version: 1.46"
}
If i comment out the header parameter i dont get any Errors, but Onesignal returns that the app id is unkown (since its missing the authorization key).
I deleted the keys in this post ofc but i got the correct keys in my Cloud script.
Any ideas ?