Sending a POST Request to a GraphQL API

Hello,

For the last few days I’ve been trying to get a set of GraphQL queries I’ve been using in Postman to scheduled an automated API call and JSON deserialization in UiPath. However, the API in question requires a GraphQL Query in a POST request body and will respond with a 400 Code in it doesn’t find one in the correct format.

From what I’ve been able to gather so far, it seems as though UiPath prefers to run Request Bodies in JSON Query format and doesn’t support GraphQL syntax too well? I was attempting to convert the query into JSON format, but it hasn’t worked yet. I also reached out to the API owners to see if they’re able to even accept JSON requests and if so if they might have an idea about conversion, but so far no luck.

For References here’s the GraphQL query I’m attemping to run in the Request Body: query {
contentProgress(first: 1000) {
totalCount
pageInfo {
endCursor
hasNextPage
}
nodes {
planId
user{
id
firstName
lastName
email
note
}
contentId
contentTitle
firstActivityOn
lastActivityOn
duration
percentComplete
}
}
}

The API in question is the PluralSight API. Here’s the endpoint (https://paas-api.pluralsight.com/graphql) and the Documentation (https://developer.pluralsight.com/)

So far I’ve been at this for about a week off and on and haven’t made much progress. Any help I could get would be greatly appreciated!

As per the official documentation, body should be in json format. I’m pasting below the format from the page:
Try creating your query as below

‘{“query”: “{ courseCatalog { nodes { title }}}”}’

Below should be your message body.

‘{“query” :"{
contentProgress(first: 1000) {
totalCount
pageInfo {
endCursor
hasNextPage
}
nodes {
planId
user{
id
firstName
lastName
email
note
}
contentId
contentTitle
firstActivityOn
lastActivityOn
duration
percentComplete
}
}
}"}’

Let me know if this doesn’t works, I will try to run it in my studio and update it.

Hi Manan,

So I tried pasting directing with the format you gave me and I got some compiler errors so I reversed the single and double quotes and I stopped getting the compiler error. However now I am getting a JSON error in the API call still. Here’s the Body I am running and the error message:

“{‘query’ :’{
contentProgress(first: 1000) {
totalCount
pageInfo {
endCursor
hasNextPage
}
nodes {
planId
user{
id
firstName
lastName
email
note
}
contentId
contentTitle
firstActivityOn
lastActivityOn
duration
percentComplete
}
}
}’}”

Thanks,
Josh

Hi Manan,

So I was able to get that example query they give to run with something similar to what you sent me, and I was able to get a response after configuring the Auth headers and everything. However, I had to change the quotations around on the initial query so it ended up looking like this: “{”“query”": “”{ courseCatalog { nodes { title }}}""}"

Now I am trying to run my query and I’m having trouble with the formatting on the larger query and the filtering elements. Currently I’m getting an unrecognized token \t error in the response:

Here’s the query I’m trying now: “{”“query”": “”{contentProgress(first: 1000) {\n totalCount\n pageInfo {\n endCursor\n hasNextPage\n }\n nodes {\n planId\n user{\n id\n firstName\n lastName\n email\n note\n }\n contentId\n contentTitle\n firstActivityOn\n lastActivityOn\n duration\n percentComplete\n}\n}\n}""}"

Thanks,
Josh