Page 1 of 1

HTTP Request POST (body)

Posted: Wed Jan 19, 2022 9:39 pm
by magnussandstrom
Hi, I am bulding a flow where I want to send a Pitstop Preflight report as a HTTP POST with the HTTP Request element. I have been asked by our dev-guy to supply the report (as json or XML) in the "body" of the POST.

In my Switch flow the preflight report (as XML) is 'triggering' the HTTP Request element, but I can't figure out how to include the preflight report as 'body' in the POST.

Or maybe I can use the 'Attatched file' but I don't understand how I could select the 'incoming' XML-file?

Any suggestions?

ps. As you might understand from my question, I am not very good at API:s (yet) ;)

Re: HTTP Request POST (body)

Posted: Thu Jan 20, 2022 8:09 am
by freddyp
If it is the XML file that triggers the HTTP request, then it is:
Request type - POST
Attached file - [Job.Path]
Use MIME encoding - No

Re: HTTP Request POST (body)

Posted: Thu Jan 20, 2022 9:17 am
by magnussandstrom
Thanks Freddy, that worked!

Re: HTTP Request POST (body)

Posted: Tue Nov 01, 2022 2:25 pm
by nfulton
What if my "body" is not in a file but rather variables I am pulling from a dataset? An example of my body is below.

{
"JobNo": "[Metadata.Text:Dataset="job",Model="JSON",Path="/JobNo"]",
"CustomerRef1": "123",
"CustomerRef2": "1234",
"Ref4": "[Job.UserFullName]"
}

Re: HTTP Request POST (body)

Posted: Tue Nov 01, 2022 6:40 pm
by mkayyyy
nfulton wrote: Tue Nov 01, 2022 2:25 pm What if my "body" is not in a file but rather variables I am pulling from a dataset? An example of my body is below.

{
"JobNo": "[Metadata.Text:Dataset="job",Model="JSON",Path="/JobNo"]",
"CustomerRef1": "123",
"CustomerRef2": "1234",
"Ref4": "[Job.UserFullName]"
}
To do this we use the Create text file app to generate a JSON file and then use the flow element properties @freddyp provided above.

Although it would be nice if the HTTP request element had functionality to be able to send a dynamic POST body rather than having to generate a file.

Re: HTTP Request POST (body)

Posted: Fri Dec 09, 2022 4:15 pm
by nfulton
I added the Create text file element, and have it generating a .json file.
Then within the HTTP request element I have the Attached file set to: [Job.Path]
When I run the flow, my MIS send back a 500 Internal Server Error and acts like it never received the body.

I have this HTTP request successfully working in Postman (where they do support a proper body). So I know the MIS API is working, it's just the problem of sending the body. For reference Tharstern is my MIS and the call is /job/update.

Re: HTTP Request POST (body)

Posted: Mon Dec 12, 2022 11:17 am
by mkayyyy
nfulton wrote: Fri Dec 09, 2022 4:15 pm I added the Create text file element, and have it generating a .json file.
Then within the HTTP request element I have the Attached file set to: [Job.Path]
When I run the flow, my MIS send back a 500 Internal Server Error and acts like it never received the body.

I have this HTTP request successfully working in Postman (where they do support a proper body). So I know the MIS API is working, it's just the problem of sending the body. For reference Tharstern is my MIS and the call is /job/update.
I'm not familiar with the Tharstern API but the only other I think you'd need to set on the request is the headers, in particular a Content-Type header. Have you got that header set on the HTTP Request element?