HTTP Script help

Post Reply
Farva
Newbie
Posts: 7
Joined: Wed Jul 07, 2021 11:14 pm

HTTP Script help

Post by Farva »

I am in need of a script to execute some HTTPS calls to a api to get some variables. They return a json but I then have to convert to XML to get the variables out. I have tried using the build in HTTP tool but the calls im using need to have a body statement and also on that is a "Patch" call. I see people referring to using the scripting module but have not been successful and really a example or guidance.

Here is a example of the call

POST 'https://website.com/fmi/data/v1/databas ... DATA/_find' \
--header 'Authorization: Bearer 18cfbff76b81ec11ac6239041444fa618d2c89328ae0f3c6b6f0' \
--header 'Content-Type: application/json' \
--data-raw '{
"query": [
{
"LI_Number": "931142"
}
]
}'
freddyp
Advanced member
Posts: 1008
Joined: Thu Feb 09, 2012 3:53 pm

Re: HTTP Script help

Post by freddyp »

I do not think you have to script it. Create a JSON file with the app "Make JSON" and post that with the "HTTP request" element. The attached file is [Job.Path] and the two headers go into the "Headers" property of course.

When you attach the return JSON as a dataset you can convert that to XML with the "JSON pickup" app.

I do not understand what you mean with "and also on that is a "Patch" call". It is not a PATCH call, it is a POST. Or do you mean that you have to execute an additional PATCH call? If that is the case and you want to script it, you will have to use NodeJS scripting. Legacy scripting does not support that.

Yet another possibility is to use "Execute command" with curl.
Post Reply