Help

Discover what data silos are costing your org in our commissioned Forrester study. Learn more

JSON rest API script

Topic Labels: Automations
678 3
cancel
Showing results for 
Search instead for 
Did you mean: 

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());

3 Replies 3

I think the issue is passing the JSON object quoted.

i tried but report: There was an unexpected error while executing your script.

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