Invoke GraphQL API using webMethods pub.client:http service

Hello,

I have a requirement to consume GraphQL query in webMethods (version 9.12).

It works fine with Postman using GraphQL feature, but somehow not able to get it to work from webMethods.

Captured the network traffic to see what is being passed from Postman, so that same format can be replicated in webMethods. Converted the GraphQL query to JSON and then feed it to pub.client:http with all required header parameters and POST method, should work, but not working.

Please guide, how to consume a GraphQA based API.

Any help is very much appreciated!

Regards,
Manoj

You can try to use “pub.string:URLEncode” by passing the GraphQL query string before invoking the client http (GET method) service.

Or for POST, you can use JSON object and that should work.

Refer, the demo graphql, which works fine in wM via client http service

https://moonhighway.com/fetching-data-from-a-graphql-api

I am able to successfully invoke the graphql endpoint. I have passed the query in below format using pub.client:http post method and the required headers like “Authorization” and “Content-Type” as “application/json”.

{
“query” : “mutation {
data(_set:
{
flag: true,
updated_by: "wM"
}, where: {account: {_eq: "1234"}})
{
affected_rows
returning {
key
updatedDate
}
}
}”
}