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:
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
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.
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:
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.