Apr 15, 2021 03:27 PM
I need a make an json request with my script,
i think the error is body: JSON.stringify because the JSON and other data is working in another script.
let response = await fetch(‘https://api.service.com/fb/sending/sendContent’, {
method: ‘POST’,
body: JSON.stringify(’
{
“subscriber_id”: 3039330322761660,
“data”: {
“version”: “v2”,
“content”: {
“messages”: [
{
“type”: “cards”,
“elements”: [
{
“title”: “Card title”,
“subtitle”: “card text”,
“image_url”: “”,
“action_url”: “https://google.com”
}
],
“image_aspect_ratio”: “horizontal”
}
]
}
},
“otn_topic_name”: “Driver”
}
'),
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer 1170be67ba0d10ac2158fb435fcd6d778'
},
});
console.log(await response.json());
Apr 15, 2021 05:47 PM
I think the issue is passing the JSON object quoted.
Apr 15, 2021 06:09 PM
i tried but report: There was an unexpected error while executing your script.
Apr 15, 2021 06:22 PM
i found the problem, had Input variables set but not used in script. Is a stupid error but i’m new here. Thank you Bill