HTTP Request with JSON object

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.

Thanks,

Hi @dari_donkuro

Your are facing issue while Post Method or Get Method?

The backend API accepts only POST request. I tried the GET but it didn’t work, because the expect body param is not passed in the GET request.

Can you share any sample string and type of method you want

if possible i will try

Sample JSON string:
“{““requestor””:““9999””,““templateId””:““tc-initial””}”
and
“{‘requestor’:‘9999’,‘templateId’:‘tc-initial’}”

Method: POST

@dari_donkuro

Can you show a screenshot of how you are pssing…

As we try the same way we have no issues…

Looks like there might be some special character…can you try opening advanced editor in the body field and then give the data as ypu need please

Cheers

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.