How can I create a http request with multi-form data including the file as a octet-stream?

Hi guys,

I try to send a PUT request to a specific company website’s api. Basically it’s a ticket system (Remedy / BMC). In this request I want to add a worklog entry (which works perfectly). But if I want to attach a file to this worklog entry I have to be very specific about my request.

I made it work in postman, but now I’m having serious trouble translating this to the UIPath’s HttpClient.

So first things first, here is the working example in my postman:

So these parameters you can see here have to be exactly like this. Even the “Key” has to be like this, otherwise it won’t work.

Now how can I create the same thing in the UIPath’s httpClient? I need to send some JSON data + the file itself with a octet-stream in a multiform/form-data request.

I tried all combinations I could think about in UIPath. I played with the headers, with the body, with the attachment properties but it won’t work.

Also in Postman I have the ability to choose a file from my computer. How can I do the same thing in UIPath? I have to use a path right? But where and how to use it exactly?

TL;DR How can I make the exact same request from the screenshot in UIPath’s httpClient?

Thx so much guys.

Hey,
how did you try with attachments ?
I sending images via UiPath when in headers I adding:


and in attachments I adding file:

Hiho @pikorpa and thank you for your message.

But how does the request know where the test.txt is physically located on the file system? On the header I have the same, except for the key. Here I have Content-Type instead of enctype.

If you have file in UiPath project folder you don’t need use full path to file otherwise you have to :slight_smile:
It’s only hint because it’s hard find straight solution without access to similar environment.
The setup which I gave you works fine for sending images for captcha.

Ok, thank you very much. The thing with this environment is it’s very strict. I have to send the request exactly as shown in my postman screenshot. Otherwise, it won’t work since it’s a very old, strict, and outdated API (which I can’t change in any shape or form).

Sorry, I don’t understand that part:

Can you elaborate in more detail to me? :slight_smile:

Ok I know what you mean. I will try that and get back to you (tomorrow). Thx :slight_smile:
Also: Where should I include my JSON Data? I have to add the json data + the data file in my request as shown in my postman. How to combine these two so it’s exactly like in postman? :question: should I also include it into the attachment (since it’s another kind of form entry), or should I include it in the request body?

I mean the test.txt file if it is in the same folder where you have UiPath project you don’t need to value input full path of the file.

I’m afraid if you want send json data you have to add JSON content to body as string. And here you have to aware because it is string and everything where you have double quotes you have to add additional two. Like in this example:
{
“something”: “qweqwe”,
“description”: “Test”,
“User”: “pikorpa”
}
you should transform to:
{
““something””: ““qweqwe””,
““description””: ““Test””,
““User””: ““pikorpa””
}

Hi @pikorpa

I tried it out today and it won’t work.
With the headers set to this:

image

And the attachments like this:

image

(the data_entry.txt contains the json - that works too in postman when sent over this file)

I get a Timeout from the request.
If I change the header to content-type (instead of enctype) I get a http 400 response.

I have no clue how I can make this work. Any more ideas? :smiley:

Bump. Wasn’t able to make it :frowning: This API is really strange.

Maybe instead form-data you will try send body using raw as xml or json ?

Hi can you please elaborate in more detail? Thank you very much.
I think I kind of have to write my own http client in a invoke code but it’s very hard for me as of right now.

Hi Team,

I got the same issue with same API. Please can anyone give us the solution for sending attachments.