Send JSON body in Http Get request

Hi Team,

I have a scenario to pass json object for get request. Am able to pass json object in “post” type request. But am not able to send json in “get” type request. I tried to pass json string in “Body” properties, but still it always sends empty body. Could you please help to send json http get request.

I attached screenshot for more reference.

The idea of the activity is that you pass parameters als collection, you dont need to create a JSON string by yourself.
https://docs.uipath.com/activities/docs/http-client

Thanks for the reply. I understand, we can pass “parameters” as a collection for . But in my scenario, my API doesn’t accept parameter it accepts “Body” only.

Have you tested this on postman client?

Hello, you need to build the body payload first. Please refer to the video below for more details. I hope it helps
https://youtu.be/q1oeuLR2Hh0

yes, its working fine in postman client.

thanks for your effort. Am also using payload only, but unfortunately the same works fine in POST request but not works in GET type request.

1 Like

For more understanding, i created my own web api. These are my following api.

     [HttpGet]
    public ActionResult<string> Get([FromBody] Input value)
    {
        return value.Value;
    }

    // POST api/values
    [HttpPost]
    public ActionResult<string> Post([FromBody] Input value)
    {
        return value.Value;
    }

I tried to call the API from Postman with the body “{“value”:“test”}”. Its working fine for both “POST” & “GET” request.

I tried the same from UiPath, but in UiPath “POST” request working as expected, but “GET” request throws error as “input was not valid”. I used the same input for all requests even in postman too.

Regards,

WebAPI Main.xaml (6.4 KB)

Sunil Prabakar C

According to the HTTP Standard, if a GET request provides a body, then the HTTP server should ignore it

A message-body MUST NOT be included in a request if the specification of the request method (section 5.1.1) does not allow sending an entity-body in requests. A server SHOULD read and forward a message-body on any request; if the request method does not include defined semantics for an entity-body, then the message-body SHOULD be ignored when handling the request.

Then in the definition of the GET method:

The GET method means retrieve whatever information (in the form of an entity) is identified by the Request-URI.

Which means that the body of such a request does not identify the requested resource, only the URI does.

The library used in the HTTP Request activity recognizes this definition and does not transmit a body for GET requests.