Upload file to backend. How does it work?

Hey,
I have been trying to upload files to my backend through appgyver with ‘Upload Files’. However, no post request is sent to the backend and no error is detected either.

The upload works on postman.

I attach the file in the body as a binary data.

In response, the file is uploaded to the backend.

On Appgyver,
I’m selecting files with ‘Pick Files’.
Then I’m sending a POST request with ‘Upload Files’ as:

Files to upload: [SET_KEY(outputs[“Pick files”].files[0],“uploadUrl”, “https://crm.mabm.io/wp-json/wp/v2/media”)]

However, the request is not sent, and yet, no error is shown by ‘Upload Files’.

Please help me. What am I doing wrong?

Also, can you please tell me how to add headers in the upload files?
Currently, I’ve been adding them as

[{value: “Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvY3JtLm1hYm0uaW8iLCJpYXQiOjE2MjA1MzY2MjEsIm5iZiI6MTYyMDUzNjYyMSwiZXhwIjoxNjIxMTQxNDIxLCJkYXRhIjp7InVzZXIiO”, header: “Authorization”}, {value: “attachment; filename=01.jpg”, header: “content-disposition”}, {value: “image/jpg”, header: “content-type”}]

Do you get any error codes when you return response? I’m getting error 200 on backendless.

I’m trying using Javascript at the moment instead of Upload component

No, I did not get any error while using ‘Upload Files’. The first output was triggered.

Can you please share your javascript code with me? I might try that as well. An error from the backend is better than no response from the backend. :slight_smile:

Im not suire how to post code blocks here

but the first things is you need to make a Javascript block with inputs llike this:

I got this code from this post:

Thankyou so much for your reply.
However,
This code requires the body of the request to be of type ‘multipart/form-data’.
My backend requires the body of the request to be of the type ‘binary-data’.

Someone please help! I’ve been struggling with this for over a week now! :sweat:

Me too = and a week too!

But that part of the code is right - you need to attach your file (binary data file) to the post, and the post sends it using the ‘multipart/form-data’.

formdata.append is supposed to handle this…

I think the problem is something to do with the body format, as someone has said, but those that did get it right and working , haven’t posted the solution!

Thankyou sooo much!!! I tried the code. But now, I’m getting an error. Like you said, there is some problem with the body. Have you been able to solve it?

Have you got Postman account >? If not , get one - its not hard but really useful for solveing this

Thankyou so much for replying. Yess, I do use postman, and I’ve been sending a post request to the backend (with the media file attached in binary) on postman. And it works.

@Vrinda_Shinde

can you check the post I made explaing how I did it?! Finally it worked!

Thankyou so much for creating this tutorial. I tried it out with my backend, unfortunately it doesn’t work. Hoping I solve this soon.

Register with backendless first and get it working with that, then move to your own backend

Hey @Sim_Sim ,
It finally worked! I had to use ‘upload function’, and after a lot of struggle, I was finally able to upload the file to the backend. :blush: Thankyou so much for your help and support.

@Vrinda_Shinde - Would you be kind enough to post your solution up here please ? that way, I can try it myself, and also it would be a help to the community

:grinning:

Yes, for-sure, I’ll create a tutorial today and post it. Really struggled with this on.