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.

REST API call with GraphQL query inside

Ihor
Giga Expert

Hi folks!

I want to send from ServiceNow REST Message which will contain GraphQL query. Preferable from FD.

Currently I just created an Action with REST step, put there my GraphQL query as a body and tried to execute and received this error:

"message": "No query string was present"
 
It works for me from Postman, because Postman has specific type GraphQL
find_real_file.png
 
If I will insert it just like a ROW, it will not work in postman, and error will be the same as I can see in SNOW in FD:
 
find_real_file.png
 
How can I modify my REST API call in SNOW to pass query as GraphQL, and not as a string? Maybe some header type or parameter?
 
Regards and thanks in advance!
1 ACCEPTED SOLUTION

Ihor
Giga Expert

Ok, I figure out. 

2 things are required:

1. Header Content-type application/json

2. query in body should be JSON.stringify ' ed

 

find_real_file.png

View solution in original post

3 REPLIES 3

Ihor
Giga Expert

Ok, I figure out. 

2 things are required:

1. Header Content-type application/json

2. query in body should be JSON.stringify ' ed

 

find_real_file.png

Johan Graden
Tera Contributor

Just what I was looking for! Thank you!! 🙌

 

KpsSumanth
Tera Contributor

@Ihor 

This is very useful, but when I am sending my variables directly its returning response, but when I am using variables it says "variable has coerced Null value for NonNull type ID!