Is there a specific way to send pdf as base64 string in a http post request?

I am able to make requests to get access token and get requests to get other data, but when converting a pdf to a base64 string using c# invoke code command, I can’t seem to make a post request whether I put the encoded string as a parameter or even in the body. It seems to take a very long time and then time out. I’ve increased the timeout and that does reveal an error, usually says either json parse error of either invalid start byte or invalid char depending on if I send the request with an attachment (using file name) or parameters (passing base64 string as a param with other necessary params).

I am able to post the files using python (outside of uipath in other words) and I know it is not an authentication problem because I am able to make other calls to the api within uipath.

Hmm tricky question

usually says either json parse error of either invalid start byte or invalid char depending on if I send the request with an attachment

Did you use ReadAllBytes / WriteAllBytes?

Maybe this can help:

I used ReadAllBytes. Interestingly increasing the timeout to 30s and passing the encodedString as a variable to the http request body worked, but it is taking a pretty long time to make each post request (like 20+ seconds each file) while doing the same requests in python is happening in seconds. Any idea about the slowness?

Sorry I have no clue why it takes so long. I have never tried it with PDF and attachment so I have no idea. Only images and there it always worked fine (as long as I keep my header intact after some pixelmanipulation).

Hello Rashan,
In this video, you can see how I upload files to multiple systems (Maybe this will help you with your issue):
Uipath upload files in Jira (REST API) (HTTP REQUEST) | Jira REST API upload file - YouTube
ServiceNow Upload files without Administrator Rights with UiPath Robots | RPA files | REST API file - YouTube
Thanks,
Cristian Negulescu

Hello Rashan,
In this video, I upload a file to Salesforce from UiPath Studio using Conversion ToBase64:

Thanks,
Cristian Negulescu