Reputation: 583
I'm using Jenkins and curl to post a file in a form that is analyzed and returns an ID that is to be used to download the contents.
My problem is how to parse the json response in order to use as my next curl get request.
This is the post command:
curl --form file=@"%WORKSPACE%\results.zip" https://host.com
This returns a json response like: {"request_id":"XXXXXX","message:null","error":false}
I want to pass the pair "request_id=XXXX" in my next curl request like:
curl https://host.com/downloadreport?request_id=XXXXX
Is there a way to do this? Saving the json response to a file and parsing it somehow? or maybe chaining both requests and manipulating the json response?
Thanks in advance
Upvotes: 1
Views: 2416
Reputation: 583
Found a partial solution:
for /f "tokens=1,2,3,4,5,6 delims=:," %%a in ("%requestId%") do set request=%%a&set id=%%b&set msg=%%c&set contents=%%d&set error=%%e&set code=%%f
It isn't very robust as it requires to know the response setup and sometimes response changes order and can't really know what is in each variable.
Upvotes: 1