Title: The REST API encountered an unexpected result
Last modified: October 28, 2024

---

# The REST API encountered an unexpected result

 *  Resolved [audioscavenger](https://wordpress.org/support/users/audioscavenger/)
 * (@audioscavenger)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/the-rest-api-encountered-an-unexpected-result-16/)
 * swg proxy + docker + wordpress image latest == php 8.2.25
 * Hi, I get this message with the normal test: **The REST API encountered an unexpected
   result**
 * The REST API is one way that WordPress and other applications communicate with
   the server. For example, the block editor screen relies on the REST API to display
   and save your posts and pages.
 * When testing the REST API, an unexpected result was returned:
 * REST API Endpoint: [https://yourdomain.com/wp-json/wp/v2/types/post?context=edit](https://yourdomain.com/wp-json/wp/v2/types/post?context=edit)
   
   REST API Response: (403) Forbidden
 * On pasting this URL ([https://example.com.test/wp-json/wp/v2/types/post?context=edit](https://example.com.test/wp-json/wp/v2/types/post?context=edit))
   in the browser, I get {“code”:”rest_forbidden_context”,”message”:”Sorry, you 
   are not allowed to edit posts in this post type.”,”data”:{“status”:401}}
 * If I change this URL to context=view ([https://example.com.test/wp-json/wp/v2/types/post?context=view](https://example.com.test/wp-json/wp/v2/types/post?context=view))
   in the browser, I get
 * {“description”:””,”hierarchical”:false,”has_archive”:false,”name”:”Posts”,”slug”:”
   post”,”icon”:”dashicons-admin-post”,”taxonomies”:[“category”,”post_tag”],”rest_base”:”
   posts”,”rest_namespace”:”wp\/v2″,”_links”:{“collection”:[{“href”:”https:\/\/example.
   com.test\/wp-json\/wp\/v2\/types”}],”wp:items”:[{“href”:”https:\/\/example.com.
   test\/wp-json\/wp\/v2\/posts”}],”curies”:[{“name”:”wp”,”href”:”https:\/\/api.
   w.org\/{rel}”,”templated”:true}]}}
 * Both seem to indicate that REST API is working, so what’s wrong and why is the
   test failing? I suspect your plugin was not vetted against PHP 8. The details
   indicate you tested it up to PHP 7.3.
 * The wordpress image provided by WordPress is using PHP 8. Were you aware?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Moderator [threadi](https://wordpress.org/support/users/threadi/)
 * (@threadi)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/the-rest-api-encountered-an-unexpected-result-16/#post-18100963)
 * Site Health (without this plugin, by the way) checks the REST API by calling `/
   wp-json/wp/v2/posts` from the local server on which WordPress is installed. It
   could be that it receives an incorrect response there, e.g. if the domain is 
   not routed correctly. I would recommend that you contact your hoster’s support
   team, they may be using a security tool that is interfering with this.
 *  Moderator [janmtm](https://wordpress.org/support/users/janmtm/)
 * (@janmtm)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/the-rest-api-encountered-an-unexpected-result-16/#post-18181364)
 * Hi [@audioscavenger](https://wordpress.org/support/users/audioscavenger/)
 * I’ll go ahead and set this as resolved for now, as you haven’t shared an update
   in over a month.
 * Please do feel free to reopen if you have more questions.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘The REST API encountered an unexpected result’ is closed to new replies.

 * ![](https://ps.w.org/health-check/assets/icon.svg?rev=1828244)
 * [Health Check & Troubleshooting](https://wordpress.org/plugins/health-check/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/health-check/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/health-check/)
 * [Active Topics](https://wordpress.org/support/plugin/health-check/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/health-check/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/health-check/reviews/)

 * 2 replies
 * 3 participants
 * Last reply from: [janmtm](https://wordpress.org/support/users/janmtm/)
 * Last activity: [1 year, 4 months ago](https://wordpress.org/support/topic/the-rest-api-encountered-an-unexpected-result-16/#post-18181364)
 * Status: resolved