HTTP Request Module - Problem with Body in POST Request

Hi guys,

I need to create a POST request against an external API in order to get an Excel file.

In the API documentation of the vendor it says, I need to add an array of strings with ids in the body of the POST request in order to receive the corresponding Excel file. So I’ve created the POST request to my workflow using the HTTP request module and added the array in the body file like this: {“res”:[“147121537”]}. However, the API doesn’t accept that. The API only accepts the plain array without the object around like [“147121537”] (tested this request with curl and it worked). But if I try to add the plain array [“147121537”] to my POST request body and start the workflow, I get an error message from the HTTP request plugin saying:

Connect: Configuring REST details
Connect: Connecting…
(‘action input JSON was invalid’, <ValidationError: “[‘147121537’] is not of type ‘object’”>)

Is there a way to only pass the array to the API?

Using CURL it is working fine:
curl -X POST -d ‘[“147105510”]’ -H “x-cookie:XXXXXXXXXXXXXXXXXXXX” -H “Content-Type: application/json” --cookie “XXXXXXXXXXXXXX” https://apix.com/export --output excel-file.xlsx

1 Like

I’ve run into this before and am trying to remember how got around it.
For some reason I want to think that I had to create the array as a member of the object then call that member in the Body

e.g.
TC → String to Object → {“body”:[12345]}
HTTP Request → Body → {{[[TC].[output].[body]}}

1 Like

Hi! Unfortunately, that doesn’t work for me. The plugin still complains that it needs an object :frowning:

Is there any way to see exactly what the HTTP Request plugin is sending to the API endpoint? Seems like that would be useful for diagnosing this and other issues with the HTTP Request plugin. I’d be keen to know how to do this as well, if it’s possible.

The Plugin is Open Source

I think the problem is that the python script is expecting a JSON object and it doesn’t recognize a JSON Array as an object.
It would be nice if we could choose JSON,JSON Array, x-www-form-urlencoded, or Text for this field because there are some APIs that I cannot use it for because of this.

2 Likes

Thanks @brandon_mcclure. Good that it’s open source, but I should have asked a better question, something like “is there a way to see - from within InsightConnect and without needing to read source code to make an educated guess - what exact request the plugin is sending?”

Some sort of “Enable debug logging” switch for plugins with request/response interaction with external resources would be really useful.