The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Sending REST request body in yml(yaml) format and parsing resposne which comes in yaml

Nishi6
Kilo Contributor

Did anyone has made rest calls by sending the request body in yaml format. If yes, can you please let me know how do i build the body and pass the parameters. 

Also if we can send the body in yaml format, how do we parse the response will also comes in yaml format. Do we have parser functions built in?

Any help is appreciated.

Thank you

 

1 ACCEPTED SOLUTION

Hi Nishi,

Sending data should be fine

But just to inform parsing the yaml response is not possible OOB with any OOB class

you will have to perform string manipulation to get the values from response

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Nishi,

I believe you can send the request body in Yaml format if the 3rd party expects that in that format.

But out of the box there is no parser for parsing yaml format similar to JSON parser.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Sending the body in yaml means passing the values something link in the screenshot below

 

Using setStringParameterNoEscape() in the script to pass the values dynamically

 

find_real_file.png

Hi,

so it looks like xml format.

any issue you are getting while consuming the endpoint?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

 

The image i have shown is XML, i have just put it for reference...

The YAML payload that i need to send to the endpoint is something like below

Phase:
  Name:  ”somebody”
  Type: “financial”
  Role: “Enhance application performance”
  Date: 12/2020
  Account: “accountid”
  Country: ""
  Number: ""

 

I haven't tried sending the payload...but trying to understand if we can send a yaml format data as the request body

Thank you.