Hello,
I am having trouble Posting to the wordpress media API. I have managed to get it working via Postman by using a binary body and selecting the image off my desktop like the below:
But when i try via Retool i get a Bad Request error:
Hello,
I am having trouble Posting to the wordpress media API. I have managed to get it working via Postman by using a binary body and selecting the image off my desktop like the below:
But when i try via Retool i get a Bad Request error:
Maybe try removing space from name? Also show us what it looks when you hover your mouse in that {{}} variable you got there in retool
I suppose it need to be decoded any tip? @ScottR @PeteTheHeat @victoria
Hey, can anyone help with this?
Hey @RossJarv!
Happy to help here.
This user using the Wordpress API + Retool got unblocked after switching their body type from Binary to Raw. Not sure if it's the same issue you're facing, but could be worth a try!
https://community.retool.com/t/unable-to-call-api-invalid-content-disposition-specified/27185/8
Otherwise, have you been able to make any other successful Wordpress queries (e.g. a simple GET query to the Wordpress API) in Retool?
Is this issue solved? I am facing the same issue :-(. The upload is done to wordpress but the image for example is empty. Do I need to encode first?
Hi @LinoPino! Would you mind sharing a screenshot of your current query?
Hi @victoria ! Thank you for reaching out and help. My issue is resolved by using formData. Works like a charm
Hi. I'm trying to do this I think - but the above responses don't spell out the actual solution.
Use case:
I have an image file in Retool storage.
I am trying to upload this image file to a WordPress API using a REST API query.
When I use Postman (as above) to upload a binary, it works perfectly.
As far as I can tell - I can only use base64 data in Retool.
I have tried many variations of content-types, but ALL I ever get are empty files uploaded to WordPress.
So - can somebody offer a breakdown of the query structure (content types, disposition, body type/content, assuming that I have a base64 string as my image?
Thanks a lot in advance!
@victoria - not sure if you're able to suggest anything here?
Hi Leon,
Did you try what was suggested in this post of using a raw body type for your request? If you did, I would be interested in if a similar request worked in Postman and what that looked like. Thanks!
Thanks Taylor. Yes, I'm using a RAW format request...
My Headers:
My Raw body:
The request:
{
"request": {
"url": "https://grassmap.uk/wp-json/wp/v2/media",
"method": "POST",
"body": "{ data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAVwAAAFcBAMAAAB2OBsfAAAAGFBMVEX71wDv7+8BAQD/////
---- SHORTENED FOR READER - --- /mG9NqzttvQ726TnusvZrnMdi9ptbe/sBbe4nO12ShWmwZXa7Xbu7lxc/g9cyo6JslLFjQAAAABJRU5ErkJggg== }",
"headers": {
"User-Agent": "Retool/2.0 (+https://docs.tryretool.com/docs/apis)",
"Content-Disposition": "attachment; filename=rugby-oslo.png",
"Content-Type": "image/png",
"Authorization": "---sanitized---",
"ot-baggage-requestId": "undefined",
"x-datadog-trace-id": "7339440347905842003",
"x-datadog-parent-id": "3921229816929747310",
"x-datadog-sampling-priority": "0",
"x-datadog-tags": "_dd.p.tid=6760389c00000000",
"traceparent": "00-6760389c0000000065daee1c4318db53-366b01be30c4816e-00",
"tracestate": "dd=t.tid:6760389c00000000;t.dm:-1;s:0;p:366b01be30c4816e",
"X-Retool-Forwarded-For": "81.133.71.235"
}
},
A couple of notes:
This precise config uploads "blank" files (of the corresponding size - 5kb) to the media library, but these do not render as images
Hey @leoncalverley! Can you try omitting the curly brackets that are wrapping the contents of the body?
The issue was solved when I faced a similar issue when I refreshed server settings/cache/cmod. Maybe it does the trick!
I'm not sure if you mean CHMOD. I'm hosting with WPEngine, so I don't think I need to modify those here.
I've tried Darren, pretty much every variant of single curlies, extra curlies... just the actual base64 data alone with nothing else.
Apologies, I wasn’t very clear. I experienced the exact same issue, but it was resolved by resetting the permissions on the server (Cloudways). Once the CHMOD permissions were set correctly and refreshed, I was able to upload files to WordPress, and the images/files displayed correctly.