Wordpress Upload attachment/image Custom Action

Is there anyone here who has been able to upload images via REST API to Wordpress?

I am struggling for days now. Feels like i am almost there, but still getting an error about side-loading. Some of you smart people who can help out?

API connection works fine and I can create posts.

Base overview:

Header 1 : Authorization is correct via Basic Authentication
Header 2:

header 3:

Header 4

for the URL i went to the file on my computer and opened the properties, and got the Path from there.


It has to do with the sideload error, the user here is Admin in WP and allowed to upload images.

The final idea would be that users can upload their images and get the URL from Adalo. But i first want to make this work

I really feel I am close but not there yet, found a lot of help online but not the right answer yet.

The best source: wordpress - WP Rest API upload image - Stack Overflow

if anyone would like to test with a test account please let me know.

Hi @Bram,

  1. To start with: What is a URL? - Learn web development | MDN

So “C:/Users/…” is a path to a local file on your PC. And Adalo custom action server (which is located somewhere in the cloud) has absolutely no access to your local filesystem.
The example on StackOverflow shows the uploading of an image from local filesystem to a local WP server (see localhost address there). That’s why it works.

  1. I don’t think that Adalo custom actions support Content-Type other than application/json (or maybe text/plain) in their HTTP requests.
    And according to the replies in the topic you’re referring to, you need to supply a binary image file. This is also confirmed in this article (Upload Featured Image to Post with WordPress REST API) - the code determines content-type by
Content-Type: ' . wp_get_image_mime( $url )

which means that it determines what is the type of the file in the $url, and after that we see

'body' => file_get_contents( $url )

which means that body is a binary stream of file contents.

  1. Also there is no way to “stream” a binary file to Adalo’s custom action.

Possible workarounds

In my opinion, you will need to use 3rd party platform like Make or Zapier - there you can create the scenario to get image from Adalo and upload it to Wordpress.
Another option could be to find some endpoint / extension to WP REST API, which accepts not only the image itself, but could also upload image using the URL.

Best regards, Victor.

1 Like

Hi Victor,

Thanks for the thorough reply, I might be stubborn willing to set this up via Adalo, which would have saved met atleast 2 days… I got it fixed with Zapier in like 15 minutes…

Now I need to get it working nice and clean with Adalo so users can make use of it in the future. Hopefully soon i can show u the results of how to make AI blogposts with Chatgpt and Wordpress.

Thanks you very much Victor great help!!!

1 Like