Can't Post to WordPress Media API

Hey, I'm trying to post to the WordPress Media API; I've looked through similar topics on here and had no luck.

I can GET, and all works fine, but when I try to post, I get this error:

I'm pretty new to Retool & APIs, so if you have a solution, please explain like I'm 5!

This issue is related to settings in your wp-config.php file. you have to define the following: define(‘ALLOW_UNFILTERED_UPLOADS’, true)

After that you are able to upload files to the wordpress media library.

Thank you! I added that but now I get a different response:

"code": "rest_cannot_create",
"message": "Sorry, you are not allowed to create posts as this user.",
"data": {
"status": 401

Any advice would be hugely appreciated!

Hi @TheFactNetwork, welcome to the forum! :wave:
The new error is related to authentication. Most APIs will allow anyone to do a 'GET' request to their server without authentication because it does not make any changes to their data (it's pure retrieval). For POST, PATCH, PUT, and DELETE is a different story. You most likely need an API key for the request.

Happy building! :hammer_and_pick:

Thanks! I managed to get that working; however, now, when I POST an image, it's showing in WordPress as a blank image... I'm really stuck here! Thank you :slight_smile:


This 'blank' issue has to do with read/write rights on your server.
Update permissions to 744 for directories and 644 for files.

Solved the issue for me.


Thanks for your fast reply, but unfortunately, that didn't work either...

I've had my host (BigScoots) look at it for hours, and they can't figure it out either. We've disabled all plugins and the theme, and it's still showing that the image is being corrupted. They said, "No server-level settings are blocking the uploads."

So now I'm wondering if there's something I'm missing in the Retool setup... although I'm not seeing any errors in Retool...

What is the response from the POST request showing in Retool? :face_with_monocle:

I've messaged you privately.

1 Like