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 the ATF REST Query Response

serviceall
Kilo Explorer

Hi

We Have an ATF test that invokes a REST API and get a 200 response code

As part of the   REST API response ,there is a Discovery Job ID that comes back.

How can we capture it as part of the ATF?

Response Body:

{"result":{"message":"Successfully created discovery job","job_id":"DIS0039467"}}

Appreciate your help.

3 REPLIES 3

VaranAwesomenow
Mega Sage

Dear Minnie,



Two things


1.Create a test step


REST test step: Assert JSON Response Payload Element

2. Assert steps must immediately follow a Send REST Request - Inbound step.


3. The Step would look like below



in your case element path would be /result/job_id and value would be the value to test against.



find_real_file.png



Result :



find_real_file.png


prash820
Kilo Explorer

I have a similar question related to this, 

 

From the Rest API response, can we use a attribute in the next step. 

 

Say I create a change using Rest API inbound call in ATF, I will get a change Number in the response JSON. Can I use the change number value in the next step?

Sagar Baver
Kilo Contributor

None of the automated REST test steps under ATF (versions <= Newyork) provide an output referencing the API response.
I believe your best option is to submit the record that you would typically create using REST APIs using ATF UI test steps and use the sys_id from the step output to make further assertions.