Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

parsing Json response body and update in table

Nishna
Tera Contributor


Please help me with the script :


I have a REST  JSON response body which contains Servers patching information  .
Now i want to update the each server(host_name) status in CMDB SERVER table based on the response from the rest message 

FYI: I have marked Server name and respective status in Bold in Below response body 

 

EX : for host_name : iac-ocbdlpat702.srv.abcd.net, got failed = true 
in this sistuation i need to update the server status as failed in CMDB SERVER table

{"count":2,"next":null,"previous":null,"results":[{"id":35432109,"type":"job_host_summary","url":"/api/v2/job_host_summaries/35432109/","related":{"job":"/api/v2/jobs/18451419/"},"summary_fields":{"job":{"id":18451419,"name":"47887","description":"","status":"successful","failed":false,"elapsed":12.686,"type":"job","job_template_id":47887,"job_template_name":"47887"}},"created":"2024-07-10T17:02:26.990059Z","modified":"2024-07-10T17:02:26.990065Z","job":18451419,"host":null,"constructed_host":null,"host_name":"iac-ocbdlpat802.srv.abcd.net","changed":0,"dark":0,"failures":0,"ok":3,"processed":1,"skipped":3,"failed":false,"ignored":0,"rescued":0},{"id":35432108,"type":"job_host_summary","url":"/api/v2/job_host_summaries/35432108/","related":{"job":"/api/v2/jobs/18451419/"},"summary_fields":{"job":{"id":18451419,"name":"47887","description":"","status":"successful","failed":false,"elapsed":12.686,"type":"job","job_template_id":47887,"job_template_name":"47887"}},"created":"2024-07-10T17:02:26.989985Z","modified":"2024-07-10T17:02:26.989996Z","job":18451419,"host":null,"constructed_host":null,"host_name":"iac-ocbdlpat702.srv.abcd.net","changed":0,"dark":0,"failures":0,"ok":3,"processed":1,"skipped":3,"failed":true,"ignored":0,"rescued":0}]}

0 REPLIES 0