Assistance Required: HTTP POST Request Failing with JSON Payload

Hi Team,

I’m currently working with the HTTP Request activity in UiPath to send a POST request to an API endpoint. The request includes a raw JSON body containing a Base64-encoded PDF file.

Here’s the JSON payload I’m trying to send:
[
{
“fileName”: “test.pdf”,
“fileContent”: “JVBERi0xLjUKJb662+4KOCAwIG9iago…base64…==”,
“mimeType”: “application/pdf”
}
]

Despite the fileContent being correctly encoded, I’m receiving the following response:
{
“Errors”: [
“Failed to parse JSON request content.”
],
“StatusCode”: 400
}

I’ve ensured that:

  • The Content-Type header is set to application/json
  • The body format is set to Raw
  • The JSON string is properly escaped for VB.NET

Could you please help me with:

  • A working .xaml sample that performs a POST request with this kind of payload
  • Any known formatting or structural requirements for the API

Hello @Muralikrishna_Surve

The Statuscode 400 indicates Bad Request so I think you are right looking at ajusting the content being sent.
I have attached an example of a Post request with a JSON body that you could check for reference.

Download here: API Post.xaml (8.6 KB)

Regards
Soren

I used my Endpoint and run this worflow.
Getting response as:
{
“Errors”: [
“The ‘useCaseId’ HTTP Header is missing in the request.”,
“The request body is missing.”,
“The ‘api-key’ HTTP Header is missing in the request.”
],
“StatusCode”: 400
}

I gave ‘useCaseId’ & ‘api-key’ in Header.

Getting response as:
{
“Errors”: [
“The request body is missing.”
],
“StatusCode”: 400
}

Just so that I understand correctly - you tried changing the example file I sent into your actual request?

If this is the case, and you get an error message indicating that the body is missing, can you verify that the variable is set?

str_Body =

HTTP Request properties =

I have updated only str_body, Endpoint and added ‘useCaseId’ & ‘api-key’ in Header.

All other properties are as it is

Getting response as:
400: {“Errors”:[“Failed to parse JSON request content.”],“StatusCode”:400}

Do you have a link to documentation on the API - Swagger or such?

Is it working fine while checking from Post man. I would recommend to test the API in post man and fix from there if there are any issues. Post successful response in post man - you can try the same using UiPath

In Postman it is working fine.

“fileContent” is getting fetched completely in Postman/

But when i use same in UiPath
“fileContent” is not getting fetching completely in UiPath. It is getting truncated.

Getting response as:
400: {“Errors”:[“Failed to parse JSON request content.”],“StatusCode”:400}

Hey thanks @SorenB & @sharazkm32.

I just changed ‘Accept Format’ from ‘Any’ to ‘JSON’.

image

Now, getting response content.

2 Likes

Great. Glad to hear. Close the topic my marking solution

1 Like

Good to hear.
That property was actually set in the example I attached so strange it caused problems in the first place.

1 Like