HttpClient activity problem while adding attachment

Hello everyone,

I’m trying to make an API call using the UiPath.Web.Activities.HttpClient activity to send an email. At first, this worked. However I have tried to add an attachment to the email in the API call. I have tried this in multiple ways. According to the activities information page it should be easily added through the Attachments Collection properties. I have tried this:

However, when I run this it will give a 400 API status with the folllowing error message:

SyntaxError: Unexpected token - in JSON at position 0

Can anyone help on how to solve this? The API call works without the attachment so that is not the problem.


Welcome to the forum

It depends on the API Definition of the

and how the attachment is expected (Form data, payload…)

Maybe you can let us know more details about the used REST Endpoint / API Docu

We do know some limitations of the HTTP Request Activity. Therefore we also do the Prototyping in Postman and depending on the resuling details we port it afterwards to the HTTP Request Activity and its settings

Thank you Peter for your answer. I now see that the attachment was expected in another way. I have tried this in Postman and it works but in UiPath it leads to a whole other question.

This is the format the API expects for an attachment:
“attachments”: [
“content”: "”
“mediaType”: “application/pdf”,
“filename”: “Test.pdf”

However the content string is a deserialized json string which in my specific situation is quite large (70k characters). It seems that UiPath has a limit for 10k characters. Which means it will not throw an error when I use the http client activity but also does not send the email. (201 status but the response api content is empty)

Is there a way to work around this issue? Thanks in advance.

can you share with us the generated curl statement from postman? thanks

Thank you

We had some reports from the past where HTTP request activity had issues with sending the call as needed to the other side. Often the specific constraints for handling attachments were mentioned.

So we do feel that a quick check and when Attachments will be handled like attachments it can or cannot work.

In case HTTP request is not to get it work we could go for a custom code e.g. with HttpClient