Image upload with POST

Hi all,

I want to upload an image (jpeg or png) which is stored locally to an REST API with the “POST Request” Node. In Postman, I’ve “developed” a PoC which also works, so the API itself seems to be OK. Authentication is done by a Bearer, works well. The content of the POST request is a piece of JSON data and the image, “Content-Type” in the header is (and must be) set to “multipart/form-data”.

Whats not working: I do not get the file up to the server, Statuscode 422. The node itself does not gives back a detailed error message (sadly).
Does anyone here has a working example of this node together with multipart form-data?
Or any hints on how to put the image into this node in a way it is accepted? I’ve already tryed it with “Files to binary object” node with or w/o Base64 encoder afterwards. In Postman, everthing works as long as I set in body the key “file” to type “file” (not text).
grafik

Thanks you in advance!

Hi Jrole,

422 means that the request is not encoded properly, seems like you’re not sending the request as multipart-encoded data.

There’s a node for building multipart requests in Palladian:

A sample workflow you’ll find here:

–Philipp

3 Likes

Thanks a lot, Philipp. Indead, I already worked on exactly this example but didn’t get the authentication working. :joy:

2 Likes

D’oh :clown_face: This shouldn’t be difficult to fix though. You mention that you have a Bearer token. You’d need to additionally supply this as input column to the HTTP Retriever with a column named Authorization which contains a string value Bearer xxxxxxxxxxxxxxx. Then select it in the Headers tab as follows and it will be sent as HTTP header:

Fingers crossed!

4 Likes

Jep, works now :slight_smile: I have another error message, but this time its coming from the API itself (422) which means: OK, you’re in.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.