How to call GraphQL API end point using REST API method or any script method?

Ganeshm1
Tera Guru

Hi All,

 

I have created a graphQL API and using the below query I am able to get the result as expected in GraphQL Explorer. 

Query:

query {
  x1306737Graphql {
    IncidentQuerySchema {
      getIncidents(
        priority: "1"
      ) {
        shortDescription
        priority
        number
        
      }
    }
  }
}



I am not getting how to pass this query in REST API POST/GET or any server side script method to get the response? Can anyone help me how we can pass this query in REST API to get the response as expected. 

 

Thanks in advance!

 

Regards,
Ganesh

2 ACCEPTED SOLUTIONS

Hi @DineshS : I tried with below query in the content and it worked fine for me. 

{"query" : "query { x1306737Graphql { IncidentQuerySchema { getIncidents( priority: \\\"2\\\" ) { shortDescription priority number } } } }"}

 

Thank you so much for your response on this question. 

 

Regards,

Ganesh

View solution in original post

DineshS
Tera Guru

Hi @Ganeshm1 , I realised the trick is to convert the GraphQL to JSON format and found the site https://datafetcher.com/graphql-json-body-converter really helpful for the conversion. Could you please try and let me know if it works ?

DineshS_0-1717098489461.png

 

View solution in original post

6 REPLIES 6

Hi @DineshS : I tried with below query in the content and it worked fine for me. 

{"query" : "query { x1306737Graphql { IncidentQuerySchema { getIncidents( priority: \\\"2\\\" ) { shortDescription priority number } } } }"}

 

Thank you so much for your response on this question. 

 

Regards,

Ganesh

DineshS
Tera Guru

Hi @Ganeshm1 , I realised the trick is to convert the GraphQL to JSON format and found the site https://datafetcher.com/graphql-json-body-converter really helpful for the conversion. Could you please try and let me know if it works ?

DineshS_0-1717098489461.png