Static JSON Payload vs Dynamic JSON payload issue in HTTP request node: json body (“JSON parameter needs to be valid JSON”)

Hi team,

I’m running into an issue with the HTTP Request node where a static JSON payload works perfectly, but a dynamic (templated) JSON payload fails with this error:

I have tried ={{ }} and .tojsonString()
none of them works

please post your json template

This is my dynamic payload, if static, it works great
{
“id”: 395,
“creationDate”: {
“dateTime”: “{{ $now.plus(2, ‘days’).format(‘yyyy-MM-dd’T’HH:mm:ss’) }}”,
“timezone”: “Asia/Dubai”
},
“shortener”: true,
“draft”: true,
“commonData”: {
“content”: “{{ $json.postContent.toJsonString() }}”,
“firstCommentText”: “”,
“publishMode”: “automatic”
},
“media”: [
{
“url”: “{{ $json.imageUrl.toJsonString() }}”,
“altText”: “Social media post image”,
“position”: 0
}
],
“saveExternalMediaFiles”: true,
“facebookData”: {
“enabled”: true,
“type”: “POST”
},
“linkedinData”: {
“enabled”: true,
“publishImagesAsPDF”: false,
“previewIncluded”: false,
“type”: “POST”
},
“instagramData”: {
“enabled”: true,
“type”: “POST”
},
“descendants”: ,
“hasNotReadNotes”: false
}

I have tried this too

{{

{

“id”: 39,

“creationDate”: {

“dateTime”: “$now.plus(2, ‘days’).format('yyyy-MM-dd\'T\‘HH:mm:ss’)”,

“timezone”: “Asia/Dubai”

},

“shortener”: true,

“draft”: true,

“commonData”: {

“content”: “$json.postContent”,

“firstCommentText”: “”,

“publishMode”: “automatic”

},

“media”: [

{

“url”: “$json.imageUrl”,

“altText”: “Social media post image”,

“position”: 0

}

],

“saveExternalMediaFiles”: true,

“facebookData”: {

“enabled”: true,

“type”: “POST”

},

“linkedinData”: {

“enabled”: true,

“publishImagesAsPDF”: false,

“previewIncluded”: false,

“type”: “POST”

},

“instagramData”: {

“enabled”: true,

“type”: “POST”

},

“descendants”: ,

“hasNotReadNotes”: false

}

}}

your json is not valid

descendants: , is wrong.

change it to

"descendants": [],
1 Like

and remove double quoutes around {{ $json.postContent.toJsonString() }} and {{ $json.imageUrl.toJsonString() }}

{
"id": 395,
"creationDate": {
"dateTime": "{{ $now.plus(2, 'days').format('yyyy-MM ddTHH:mm:ss') }}",
"timezone": "Asia/Dubai"
},
"shortener": true,
"draft": true,
"commonData": {
"content": {{ $json.postContent.toJsonString() }},
"firstCommentText": "",
"publishMode": "automatic"
},
"media": [
{
"url": {{ $json.imageUrl.toJsonString() }},
"altText": "Social media post image",
"position": 0
}
],
"saveExternalMediaFiles": true,
"facebookData": {
"enabled": true,
"type": "POST"
},
"linkedinData": {
"enabled": true,
"publishImagesAsPDF": false,
"previewIncluded": false,
"type": "POST"
},
"instagramData": {
"enabled": true,
"type": "POST"
},
"descendants": [],
"hasNotReadNotes": false
}
1 Like

hey @ramin1 did this help you resolvee the problem, cos i am also having this asme mess now.

i did not understand. i helped krishnapallapolu to solve the problem,

1 Like

sorry, it may not be descendant issue, becuase, I can see it like an array in my template and for sure it was removing the double quotes on the {{ $json.postContent.toJsonString() }} that helped

oh my bad, i am very sorry

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.