I’m trying up POST jpg-files via REST API but doing it from UiPath results in an image-file that can’t be read. The server receives the file but as “mime”: “application/octet-stream”,
If I do the same operation from Postman the file is perfectly posted as “mime”: “image/jpeg”.
I can not understand what is wrong. I’m told to use form data but when adding that to the headers (Content-Type, Direction: In, Type: String, Value: “multipart/form-data”) I end up with an error message saying:
400 {“error”:“bad_request”,“error_description”:“No uploaded file found. Please upload the file using the multipart/form-data specification”}
Currently I use no headers and no parameters. Only Body format set to multipart/form-data
I’ve read many threads with similar issues but nobody seems to have sorted this out. Anyone succeeded? Since it works so well from Postman I’m starting to think that HTTP Request may be buggy.
Yes, absolutely. Here is my current example. As you can see the receiving server sees this as “mime”: “application/octet-stream” instead of “mime”: “image/jpeg”, that it should be.
Using Postman or cURL does the job perfectly with no problem what soever. With UIPath I have struggled numerous hours without success.
Searching the forum for “post form-data” or “HTTP Activity POST Attachment” will give many threads of people loosing their hair over this issue.
I’m using 2020.4.2.
I see that your BodyFormat value is “form-data”, which is not a valid MIME type. Don’t worry about it, as the HTTP Request activity automatically uses the valid “multipart/form-data” MIME type if you add an attachment, as you did.
I’m not sure what the logs that you’ve attached represent. They don’t seem to be request headers and I’m not sure what the expected behavior is in your case. I think that this has more to do with your web server than with the HTTP Request activity configuration.
Here’s a sample of how I’m using the same activity with good results.
and the file gets uploaded in the designated folder and can be easily opened with any photo viewer app.
My best guess is that you’re somehow trying to process the image on the web server and you’re not getting the results you want, but that doesn’t mean that the HTTP request (i.e. the actual request, not the activity) is not well formatted.
Can you please explain your second screenshot a bit better? How are those properties generated? Can you also paste the raw incoming request headers?
Hi! Thank you for the response.
The code I pasted is the response from the server showing that it does not understand the mime-type. As this is working flawlessly using cURL or Postman I do not see any reason to suspect any error on the server side.
I’m afraid I don’t have the skills to set up a server to listen to incoming request. The server I’m trying to upload to is a large e-commerce platform.
Looking at your screen shots I can’t spot anything that differs besides “form-data” but as you say that shouldn’t make any difference. No sure how I could present more details as the HTTP Request activity basically only contains the Endpoint, Attachment and credentials. Not much to do wrong I suppose.
I understand there is a difference between Postman and HTTP Request, but it seems like the activity is doing what it should, so I can’t figure out what your server does that makes it disregard the fact that the activity is sending sending an image. I can assure you that all of the image’s bytes reach the server.
I will try to investigate further what the difference might be. If you come across some new information, please post it here.
I have some doubts about the use of the Http Activitie, I could not find any conversation talking how to do the http request with attached files like this, so please @loginerror could you help how can I do to use the UiPath activitie with the next example, I think it colud be very useful for the communitie, I want to use de API of an OCR IA Model but it is working in Postman, but I cant do it work in UiPath, see information below:
#1 Process file using multipart/form-data upload
Submit a request to process a multipart/form-data file upload.
HTTP Request
POST https://ENVIRONMENT_URL/api/v7/partner/documents/
Query Parameters
Field
Type
Required
Description
file_name
String
Y
File name (eg. starbucks.jpg)
file
File
Y
File (pdf, jpg, .jpeg, .png)
categories
List
N
List of categories, if you would like to use your own list and it’s different from the Default one [“Meals & Entertainment”, “Travel”, …]
max_pages_to_process
Int
N
When sending a long document to Veryfi for processing, this paremeter controls how many pages of the document will be read and processed, starting from page 1.
boost_mode
Int
N
Flag that tells Veryfi whether boost mode should be enabled. When set to 1, Veryfi will skip data enrichment steps, but will process the document faster. Default value for this flag is 0.
external_id
String
N
Optional custom document identifier. Use this if you would like to assign your own ID to documents
Have you already tried the method explained above?
Remove your credentials and try sending both requests - from Postman and from Studio - to the same random URL of webhook.site.
Then, please compare the two received requests to see if there are any differences. Feel free to provide screenshots as well, together with the setup you have in Studio properties panel for your HTTP Request activity.