how to capture the id request number from API ?
for example we stop the service - AMBARI_METRICS
and we get the id - 128 from output , so we can use grep to capture the id , but we prefer other elegant way ,
curl -u admin:admin -i -H 'X-Requested-By: ambari' -X PUT -d '{"RequestInfo": {"context" :"Stop AMBARI_METRICS via REST"}, "Body": {"ServiceInfo": {"state": "INSTALLED"}}}' http://localhost:8080/api/v1/clusters/sys15626/services/AMBARI_METRICS
HTTP/1.1 202 Accepted
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Cache-Control: no-store
Pragma: no-cache
Set-Cookie: AMBARISESSIONID=19rvqn2cgzwb51sfevywdfvwm7;Path=/;HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
User: admin
Content-Type: text/plain
Vary: Accept-Encoding, User-Agent
Content-Length: 137
Server: Jetty(8.1.19.v20160209)
{
"href" : "http://localhost:8080/api/v1/clusters/sys15626/requests/128",
"Requests" : {
"id" : 128,
"status" : "Accepted"
}
Michael-Bronson