Hi,
following the custom action guide, I tried to do an outbound HTTP call with a POST request. In the request body I added the corresponding JSON (according to the description in the UI wizard: "Specify the body of your request in JSON format. You can use the selector ({...}) to pass Intercom attribute values in your request body.") like this:
{
"ownerEmail": "ash-ketchum@example.com",
"pet":"Pikachu"
}
When retrieving the call in my application, I see the following HTTP request coming in:
POST /my-endpoint HTTP/1.1
Host: myserver.com
User-Agent: Faraday v0.17.3
Content-Length: 66
Accept: */*
Accept-Encoding: gzip,deflate
Content-Type: application/x-www-form-urlencoded
Date: Fri, 01 Jul 2022 12:19:53 GMT
{
"ownerEmail": "ash-ketchum@example.com",
"pet":"Pikachu"
}
The problem is that the "Content-Type" HTTP header is set to "application/x-www-form-urlencoded" instead of "application/json".
Therefore my application framework will reject the request, as the HTTP body does not match the content type.
I'm able to change the body of the HTTP call by using the format of "application/x-www-form-urlencoded" like this:
ownerEmail=ash-ketchum%40example.com&pet=Pikachu
but I'm not sure if this is how I should do it, as the description explicitly says it should be JSON.
I am also able to override the HTTP header explicitly in the wizard (and this actually works), but I was wondering why the default value is "application/x-www-form-urlencoded".
Cheers
Mario