Zendesk API Attach files

Hi guys,

I’m trying to replicate in UiPath the HTTP request created in Postman - see image below

In order to attach a file(image in my case) with the HTTP request, I’ve used my file location in the “Attachments” Options.
I’ve added BodyFormat “application/binary” and as Headers I have my authorization token + Content-Type as “application/binary”.

Unfortunately the file that is attached is of an unknown type - not recognized as an image.

Any ideas how to solve this? Or how to add a binary file in UiPath on a HTTP request?

Thanks a lot in advance!

1 Like

We have attachments option where we have to attach the files for the request. Just try to pass the same headers and body even the URL parameters (Query params) same as post man and check what is the status you are getting

Hi HareeshMR,

Yes, I’m using the Attachment option, where I’ve added the path of the local file that I want to pass by.
Headers, URL parameters are exactly the same, the body is empty. But is not working

same problem exist for me also…do anyone in this forum knows what is wrong ?
do we have to mention the file to be attached in body property of uipath and body format as application/Any?

Can you please post the error you are getting so that it will be easy to identify the issue @CristianR88

@HareeshMR Unfortunately I don’t get any error

On the image above, you can see I’ve attached 2 files to the ticket.
The one on the bottom is what I’ve uploaded via POSTMAN, and the one on top is using UiPath http request. So my guess is that something on the UiPath’s request is not correct/working.

Below are the exact params that I’m using in UiPath in case you see something missing or incorrect

Have you found a solution? I’ve got a similar problem. In my case with Postman works fine. Trying to replicate the same configuration in an HTTP request of Uipath I can post the file, but I can’t open it once posted.(my file is a .msg of Outlook).
I found that inside the file has been added on top and at the bottom some rows. Any idea?
For the name untitled I suggest you to insert a row in the header with the key Document-Name and as value the name of the file.

@ro.bot and @CristianR88

Did you find the solution, guys?

Thanks

Guys, I started to work in this same task today.

I tried exhaustively using HTTP Client activity, and always I got success status but the image was kind of broken, such as your case.

After lose all my day, I gave up and decided to implement in a different way, using invoke code activity.

Here you go the solution:

First, add RestSharp dependence to your project

After that, import RestSharp

Then, add an invoke code activity

image

Finally, add the following code:

    Dim client As RestClient = New RestClient("https://{{replace}}.zendesk.com/api/v2/uploads.json?filename=vaibrasil.png")
    client.Timeout = 10000
    Dim request As RestRequest= New RestRequest(Method.POST)
    request.AddHeader("Authorization", "Basic {{replace}}")
    request.AddHeader("Content-Type", "image/png")
    request.AddParameter("image/png", File.ReadAllBytes("C:\Users\gustavo.cervelin\Downloads\vaibrasil.png"), ParameterType.RequestBody)
    Dim response As IRestResponse = client.Execute(request)
    Console.WriteLine(response.Content)

IMPORTANT NOTES:

  1. Replace {{replace}} at first line with you subdomain;
  2. Change filename parameter value at first line;
  3. Set timeout as you want at second line;
  4. At line four, replace {{replace}} with your email+token combination (base 64);
  5. At line five, set the content type according your file extension;
  6. The same for line six

That’s it guys!

If you need help to work with the response, let me know

2 Likes

Hello Cristian,
In this video I upload a file to salesforce using Base64:

Thanks,
Cristian Negulescu

só tem esse jeito mano?

1 Like

@Felipe_Lopes,

Na época que eu estava trabalhando nesta integração com o Zendesk (Abril de 2020), eu tentei muito fazer funcionar utilizando HTTP Request activity. Mas não consegui :frowning:

Então, me veio a ideia de fazer por linha de código com a Invoke Code activity e deu certo :slight_smile:

Se é o único jeito? Não consigo te afirmar 100% pois parei de explorar outras possibilidades depois que a segunda opção (Invoke Code) deu certa.