C
C
copyerfiled2016-10-14 15:50:25
bash
copyerfiled, 2016-10-14 15:50:25

How to put in a variable the value from the JSON response of a POST request made via curl in a bash script?

Actually in simple words:
There is a magic API for the magic helpdesk.
There is a magic script that runs on a linux machine.
This script takes CURL, sculpts a POST request on it and throws it into the helpdesk API.
The helpdesk eats up the request and spit out JSON data. An example of such a plan: { "ticket": "#ABC-1234", " blablabla
": "i td i tp"}
script. Something until I understand even from which side to approach it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
copyerfiled, 2016-10-14
@copyerfiled

In general, I managed to capture it myself with the following capture:
put jq
Add to curl request:
| jq -r '.ticket' We capture
the whole thing in a variable by placing between the brackets TICKET=$( here )
We
get $TICKET=#ABC-1234

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question