GraphQL API configuration on Azure API gateway

SrikanthReddy60
ServiceNow Employee
ServiceNow Employee

Does anyone have any idea on how to register the ServiceNow platform-provided graphQL API endpoint on the Azure API gateway? 

 

I looking for some information on registering and fetching results on the Azure API gateway from the graphQL API endpoint. 

 

 

2 REPLIES 2

Syedmd08
Kilo Guru

Yes, it is possible to register the ServiceNow platform-provided GraphQL API endpoint on the Azure API gateway. Here are the steps you can follow:

  1. Create an API Management instance in your Azure portal.

  2. Create an API by going to the "APIs" tab and selecting "Add API". Provide a name, description, and the endpoint URL for your ServiceNow GraphQL API.

  3. Next, create an operation in the API by selecting the "Add operation" button. Give it a name, and then set the URL template for the GraphQL query. The URL template should be in this format:/<graphql_endpoint>?query={query}&variables={variables}

  1. Replace <graphql_endpoint> with the endpoint for your GraphQL API. This template allows the Azure API gateway to forward GraphQL queries to the ServiceNow platform.

  2. Set the method for the operation to "POST".

  3. In the "Policies" tab for the operation, add a policy that sets the HTTP header for the request. This header is required for ServiceNow's GraphQL API. Add this policy code:

<set-header name="Content-Type" exists-action="override">
<value>application/json</value>
</set-header>

 

  1. Save the operation and publish the API.

  2. Finally, test the API by sending a GraphQL query to the Azure API gateway. The query should be sent using a POST request, and the body should be in JSON format. Here's an example query:

{
"query": "{table {sys_id number}}"
}

 

  1. Replace "table" with the name of a table in ServiceNow. This query fetches the sys_id and number fields for all records in the table.

That's it! You should now be able to register and fetch results from your ServiceNow platform-provided GraphQL API endpoint on the Azure API gateway.

 

Please mark my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Thanks for the detailed steps