when inputting the “Text” in the “http Request” activity it is really troublesome due to formatting issues. Most of these result from the fact that quotation marks cannot be used.
I recommend to improve this field. It would be great to be able to invoke code. So that one must not transform the code before entering it into UiPath.
Or perhaps there are other suggestions?
I know I could save the code in a file and import it as a variable. Not the best option either.
I did not quite understand your example, but I can give one. Perhaps we talk about the same:
How the code (HTTP Request, GraphQL) works in another system:
{
product(context: "...", workspace: "...", id: "...") {
children {
pageElements {
id
name
objectType {
id
}
values {
attribute {
id
}
simpleValue
}
}
}
}
How I have to input it in UiPath:
"{product(context: \"+Chr(34)+"...\"+Chr(34)+", workspace: \"+Chr(34)+"...\"+Chr(34)+", id: \"+Chr(34)+Variable+"\"+Chr(34)+") {
children {
pageElements {
id
name
objectType {
id
}
}
}
}
}"+Chr(34)+"
}"
That is due to Chr(34) instead of quotation marks.
Further if one adds further spaces or changes the code directly in UiPath it does not work due to formatting issues.
e.g., I have added “name” in a new line in the existing UiPath text: It did not work.
When I copy the text from id to id into it, it works, despite being exactly the same.
If I understood your struggle correctly, then the simple way to explain it is that the double quotation mark " can be escaped by another double quotation mark "" when used in the expression.
Still, I understand that it can get quite complex when working with GraphQL queries.
Fetching your query from a file is actually one of the better and easiest options, as you pointed out earlier:
I know I could save the code in a file and import it as a variable. Not the best option either
If this is not desired, then another option would be to go a slightly more advanced route and use the Coded Workflow .cs files together with the GraphQL .NET library. This way you could either create your desired query object with code, or even execute it directly (given that you already have the GraphQL library at that point).
One thing that makes it difficult to work with these activities in UiPath is that it is very sensitive to spaces. I have tested it using a .txt file and directly changing code in the activity.
Using http requests in other tools is not that sensitive to the number of spaces.
Therefore, this could be an improvement.
Otherwise, it will lead to frustration since it is easy to forget a space sign. And copy/paste from other tools where one often tests the Requests is not really possible.
I know that we already have a sample in this topic, but I am curious about those spaces.
Would it be possible for you to provide two dummy samples, one that works and one that breaks due to too many spaces? I’m curious and I would really like to figure out why this happens.
Together with the second, broken sample (due to spaces), it would help to learn the types of errors that you are encountering due to that.
Conclusion based on our chat: the problem was the TAB characters in the Body property in the HTTP Request activity. The activity sends them as they are without replacing them with white spaces, and it was not being received well by the target service.