Body Content for Custom App

Hi,

I’m setting up a custom app with multiple requests. The second request requires me to add content to the body of the request directly in the communication tab of the module. I keep getting an error and i know its from the way i add the json into the body. Here is the request structure:

{
	//	Step 2: Add or Update Contact Associated List	
	"url": "https://api.sendgrid.com/v3/marketing/contacts", 
	body": "JSON HERE",
	"type": "text",
	"method": "PUT",
	"headers": {
		"{{...}}": "{{toCollection(parameters.headers, 'key', 'value')}}"
	},
	"response": {
		"output": {
			"body": "{{body}}",
			"headers": "{{headers}}",
			"statusCode": "{{statusCode}}"
		},
            "error": {                                        
			"message": "[{{statusCode}}] Update Contact Associated List"
		}
	}
}

and here is an example of the json structure.

{
  "list_ids": [
    "list_id_1",
    "list_id_2"
  ],
  "contacts": [
    {
      "email": "example@example.com",
      "first_name": "John",
      "last_name": "Doe"
    }
  ]
}

Any help with how to write the json directly inside request body above, especially because the body content also has a json inside it.

Thanks.

Hello!

Can you try to escape the double-quotes with a \ in your json, and change the type to “json“?

Benjamin

1 Like

@Benjamin_from_Make Thanks, I already figuired it out. Thought to post it here just incase someone else needs it. The body content will look like this:

	"body": {
		"list_ids": ["list_id_1","list_id_2"],
		"contacts": [{
			"email": "example@example.com",
			"first_name": "John",
			"last_name": "Doe"
		}]
	}

Cheers.

3 Likes

This topic was automatically closed after 31 days. New replies are no longer allowed.