GraphQL API Query Syntax Error when using filter

Hi

I am trying to pass a POST query using GraphQL with HTTP Request activity from UiPath.WebAPI.Activites. I can get the query to work with Postman, but having trouble with UiPath when I apply filter to the query.

I am reading the request body from text file, and using it as a string variable in UiPath.

When I try this query (no filter) in UiPath:
{
“query”: “query{ recentTransactions (last:100) { edges{ node { createdAt transactionHeader { postedDate transactionNumber } text account { code } amount } } } }”
}

->it works well and I get expected result.

However, when I try to apply filter:
{
“query”: “query{ recentTransactions (last:100, filter: {createdAt_gte: “2022-12-12T00:00:00”}) { edges{ node { createdAt transactionHeader { postedDate transactionNumber } text account { code } amount } } } }”
}

->I get result in output file:
{“errors”:[{“message”:“Invalid JSON syntax.”}]}

If I try this query in Postman, it works as intended:
image

Having trouble using the filter with UiPath.
I suspect this has to do with the quotation marks that are required around the datetime.

Does anyone have any idea how I can make the syntax correct? Tried using double and triple quotation marks around the datetime, but I get the output file always says “Incorrect Json Syntax”. Help appreciated

Hi @Oscar_Ram_Kalia

I guess you wrote it wrong You missed a curl brace

image

cheers

Hey

Thanks for pointing it out, that was just a fault with my post.

Edited the post now.

I tried the API call again, with the bracket in place, but syntax error still shows up. When I tried earlier, it was with the bracket as well, so I am still unsure how to fix this issue.

@Oscar_Ram_Kalia

Try giving double double quotes may be it is getting by passed

Can you show how exactly are you passing the arguments

Cheers

Hi

I tried using double quotes as well, but still get the message “Invalid JSON Syntax” from output file.

This is what I now put in the text file containing the request body:
{
“query”: "query{ recentTransactions (last:100, filter: {createdAt_gte: ““2022-12-15T00:00:00"”}) { edges{ node { createdAt transactionHeader { postedDate transactionNumber } text account { code } amount } } } }”
}

I am reading the body from text file and passing it as a string variable in HTTP Request activity like this:
image

This works fine without the filter (see original post), and I can get the correct result from UiPath in that case. I can also successfully use the filter in Postman, and get correct result. The problem arises when I try and apply the filter to the call in UiPath.

Appreciate any more tips

@Oscar_Ram_Kalia

I guess this is what is valid json…can you try this please. Escaped "(double quotes) with \(backslash)

{
	"query": "query {recentTransactions(last: 100, filter: {createdAt_gte: \"2022 - 12 - 12 T00: 00: 00\"}) {edges {node {createdAt transactionHeader {postedDate transactionNumber}text account {code}amount}}}}"
}

cheers

1 Like

Thank you, that seemed to solve it! :slight_smile:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.