# HTTP Request with JSON object

**URL:** <https://forum.uipath.com/t/http-request-with-json-object/572231>\
**Category:** Activities\
**Tags:** web, webapi, activities\
**Created:** [August 11, 2023, 6:25pm UTC](https://forum.uipath.com/t/http-request-with-json-object/572231 "2023-08-11T18:25:34Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dari\_donkuro](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/dari_donkuro/32/74359_2.png) [@dari\_donkuro](https://forum.uipath.com/u/dari_donkuro)\
**Post date:** [August 11, 2023, 6:25pm UTC](https://forum.uipath.com/t/http-request-with-json-object/572231/1 "2023-08-11T18:25:34Z")

</div>

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](http://VB.Net) language.

Thanks,

---

<div class="post-metadata">

**Author:** ![Shiva\_Nikhil](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/shiva_nikhil/32/267408_2.png) [@Shiva\_Nikhil](https://forum.uipath.com/u/Shiva_Nikhil)\
**Post date:** [August 11, 2023, 6:35pm UTC](https://forum.uipath.com/t/http-request-with-json-object/572231/2 "2023-08-11T18:35:30Z")

</div>

Hi @dari_donkuro

Your are facing issue while Post Method or Get Method?

---

<div class="post-metadata">

**Author:** ![dari\_donkuro](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/dari_donkuro/32/74359_2.png) [@dari\_donkuro](https://forum.uipath.com/u/dari_donkuro)\
**Post date:** [August 11, 2023, 6:52pm UTC](https://forum.uipath.com/t/http-request-with-json-object/572231/3 "2023-08-11T18:52:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Shiva\_Nikhil](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/shiva_nikhil/32/267408_2.png) [@Shiva\_Nikhil](https://forum.uipath.com/u/Shiva_Nikhil)\
**Post date:** [August 11, 2023, 6:59pm UTC](https://forum.uipath.com/t/http-request-with-json-object/572231/4 "2023-08-11T18:59:41Z")

</div>

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

if possible i will try

---

<div class="post-metadata">

**Author:** ![dari\_donkuro](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/dari_donkuro/32/74359_2.png) [@dari\_donkuro](https://forum.uipath.com/u/dari_donkuro)\
**Post date:** [August 11, 2023, 7:19pm UTC](https://forum.uipath.com/t/http-request-with-json-object/572231/5 "2023-08-11T19:19:40Z")

</div>

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

Method: POST

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [August 12, 2023, 5:57am UTC](https://forum.uipath.com/t/http-request-with-json-object/572231/6 "2023-08-12T05:57:59Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![dari\_donkuro](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/dari_donkuro/32/74359_2.png) [@dari\_donkuro](https://forum.uipath.com/u/dari_donkuro)\
**Post date:** [August 13, 2023, 6:42pm UTC](https://forum.uipath.com/t/http-request-with-json-object/572231/7 "2023-08-13T18:42:44Z")

</div>

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](http://VB.Net) didn’t compile in code activity. [VB.Net](http://VB.Net) is a new land for me.

---

<div class="post-metadata">

**Author:** ![dari\_donkuro](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/dari_donkuro/32/74359_2.png) [@dari\_donkuro](https://forum.uipath.com/u/dari_donkuro)\
**Post date:** [August 14, 2023, 2:31am UTC](https://forum.uipath.com/t/http-request-with-json-object/572231/8 "2023-08-14T02:31:09Z")

</div>

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](http://VB.Net).

 ![RestSharp](https://global.discourse-cdn.com/uipath/original/4X/f/0/1/f014123ae73a0958810bddd090cbc7f21a820e4f.png)
