Hi,
I am using HTTP Request Activity to call an API. The body of the request is a simple JSON string. However, when I send the request I get “A JSONObject text must begin with ‘{’ at 1 [character 2 line 1]”
Here my JSON body:
“{““requestor””:““XXX””,““templateId””:““templ””}”.
I also use Deserialize activity to deserialize the JSON string before passint it to HTTP Request Activity, but gave the same error.
Furthermore, I also tried “{‘requestor’:‘XXX’,‘templateId’:‘templ’}”, but still getting the same error.
I concluded that HTTP Request activity is buggy, because I am calling the same API and the same JSON data in Postman and it works there, no json format error.
Next, I want to use invoke code activity to write a custom code to call the API with JSON data, however, after trying some sample code from online, the samples give errors in invoke code activity.
Please, help with custom code to use in invoke code activity. The project is using VB.Net language.
Please, find the screenshot of the parameters passed. As I mentioned in the post. I am using the same parameters in postman and it works well, except in UiPath studio. I have tried so may ways, including UiPath WebAPI versions, studio platforms (Windows-Legacy, Windows) and non works. That why I am more interested in using invoke code activity to call API from there, but the samples I found online about REST in VB.Net didn’t compile in code activity. VB.Net is a new land for me.
I was able to write C# code to make the API code, after a refresher on C# language.
For those who are still stuck with the HTTP Request activity, don’t waste any more time on it. Just use this same code in Invoke Code activity and provide your request body and headers as needed. Change the language to C#, if your project is VB.Net.