rest_forbidden for media #2596
Comments
What user are you authenticating as, and what capabilities do they have? At the very least it is a really bad error message. |
Perhaps this is the same issue as #2571 |
No authentication. I am just doing a GET, not a POST.. for SOME media posts, a simple /wp-json/wp/v2/media/6639/ returns the above. Most of media posts work fine. I can't tell what the difference between them are.. |
@rafalSuntimes if the attachment is attached to an unpublished post, you won't be able to read it. Is that the case here perhaps? |
@joehoyle Thanks. That solved it in my case. |
Closing out, no response from the reporter in a month. |
This issue is still happening with public, published posts. On my site everything is published and public. The 403 error when accessing certain media is seemingly random. |
@drewhallett Can you open a ticket on the WordPress support forums (at https://wordpress.org/support/forum/how-to-and-troubleshooting/ with the topic tag "rest-api") or bug tracker (at https://core.trac.wordpress.org)? This repository's issues are unfortunately no longer being tracked |
We are experiencing this bug as well; if a bug has been filed, can you post a link to it here so that we can follow it? |
I discovered this randomly appearing bug too. 403 error when accessing media of some public published posts. Any news on this topic? |
There is something weird related to the issue. I've uploaded a featured media on the "Pages" page, after that, I create a new post and pick up the same image uploaded on the "Pages" page. It causes the error that I posted above. But if you create a new post and upload a new image it works fine. |
Yeah, seeing the same problem here. Public post, still not letting the media embed, but it seems to work fine most of the time. |
Same issue here:
"code": "rest_forbidden", What role is required at minimum to access media? Seems that when i get all media i also see a subset? Update: Seems to be related to WP Offload S3 Lite plugin that has not yet uploaded these images.... |
Okay, based on what I've seen in the DB, I have more input regarding this evil issue. A workaround if your media is related to a Hope this helps. |
I just experienced the same issue. The image was originally uploaded as a featured image to a post which has been set to draft since then. This caused the image to not showing up in the API when used as featured image for a newer post. |
@rmccue can we reopen? There are plenty here that are seeing this and it seems like a cause has been identified as well. I'm seeing exactly the same thing; a featured image was uploaded with a post, then reused as the featured image on another post and the original post was moved to the trash. The REST API refuses to embed the featured image correctly on the new post. Somewhat related: https://core.trac.wordpress.org/ticket/30691 |
This repo is no longer used for tracking issues. If you're still experiencing this issue, please file it on Trac, or comment on an existing issue there. |
Thanks, will do. I've commented on that issue but that's not really the core focus of it, so I'll open another. |
Added as https://core.trac.wordpress.org/ticket/41445 if anyone else with the same issue wants to track progress on a fix. |
Hii All.. Any update for this issue.. because i get same issue.. 😢 |
Same here. I found this issue today after 1700 posts without any problem. |
I found a solution for my case: Its related with the media name (url) and and the special chars. After a while i discover that is about the name of the pic, in my case: PeñaNieto.jpg The "ñ" and other special chars, could cause this error. |
Glad that worked for you @VictorPurMar, looks like you've found another cause for the problem. There has been no progress on fixing the underlying issues covered in these reports |
A patch has been submitted here: https://core.trac.wordpress.org/ticket/41445 |
Thanks @StuartFeldt, nice to finally have a fix for this. |
@VictorPurMar I agree with you. I had underscores and dashes in the image name. removed them and re-uploaded the image. Now its working fine. |
Uh guys sorry but
Uh this is not the one that works, sorry. It is a very strange issue. I own the site "muharrir.net" which is a Turkish website. It hosts many Turkish-character-including names of images. We are developing an Android app for it and today suddenly we experience the crash. We were OMG-ed and tried the resolve the issue. The fastest workaround we could come up with was surrounding the processing code with: if (code == null || !code.equals("rest_forbidden")) { //java code to process } Plus, see the uploaded images. Both contains Turkish-specific characters like "ı" and/or "ş". "ŞU TARAFA DOĞRU" has no errors or crashes, I get the images perfectly. No code or error returns. But the latest post that caused our app to crash has the issue. It has "ı"s all over. But I don't see any difference in both. Both contain non-ASCII characters anyway. It really looks like a random issue to me. Just FYI. |
@besrabasant the hashes and dashes are a red herring, it was the reuploading that fixed it for you - as described above, the problem is related to the permissions of the post it was originally uploaded against, uploading again to a different post will resolve the problem. The underlying problem was identified and raised as an issue in WP's trac more than a year ago now, with a patch now available (but @StuartFeldt has not responded to the comments on the patch there yet) but not yet merged. |
I am getting the following JSON object in a response for http://localhost/wp-json/wp/v2/posts/somePostID?_embed
also, wp-json/wp/v2/media is an empty array.
Is this a bug, or am I doing something wrong?
The text was updated successfully, but these errors were encountered: