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)
HTTP Request POST (body)
- magnussandstrom
- Advanced member
- Posts: 358
- Joined: Thu Jul 30, 2020 6:34 pm
- Location: Sweden
- Contact:
Re: HTTP Request POST (body)
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
Request type - POST
Attached file - [Job.Path]
Use MIME encoding - No
- magnussandstrom
- Advanced member
- Posts: 358
- Joined: Thu Jul 30, 2020 6:34 pm
- Location: Sweden
- Contact:
Re: HTTP Request POST (body)
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]"
}
{
"JobNo": "[Metadata.Text:Dataset="job",Model="JSON",Path="/JobNo"]",
"CustomerRef1": "123",
"CustomerRef2": "1234",
"Ref4": "[Job.UserFullName]"
}
Re: HTTP Request POST (body)
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.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]"
}
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)
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.
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)
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?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.