• When I do a post (create order on WooCommerce) to the V2 rest api, I get:

    <head><title>Document Moved</title></head>\n<body><h1>Object Moved</h1>This document may be found <a HREF=\"https://<domain>/wp-json/wc/v2/orders/21658\">here</a></body>{"id":21658,"parent_id":0,\number\":"21658","order_key":....

    I saw the same issue here so I assume it is IIS related. I run on IIS on Plesk (let’s not have a discussion on why I should not run WordPress on IIS, I need it and it is officially supported).

    For clarity, the new order created is part of the response, and the ID number is the number of the new order.

    But the response should not contain HTML, and there is no reason to have that message in the first place.

    Is this a bug, or is there something that I can change?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    The REST API only sends valid JSON responses. This HTML is apparently something injected by IIS. If there is something in the response that can be changed to prevent IIS from doing this, you have a chance for a fix. For example, if different or additional headers need to be sent, use the ‘rest_post_dispatch’ filter, from which a WP_HTTP_Response object is passed. You can check and modify headers using the class’ methods.

    Unfortunately, I’ve no idea why IIS would behave this way or how to prevent it.

    Thread Starter vankampenp

    (@vankampenp)

    This is not very helpful.
    It happens on Azure, as well as on Plesk, so it is wide spread on ISS. Anyone who can find out why IIS does this?
    Does WordPress return a 301 status code?

    Moderator bcworkz

    (@bcworkz)

    Returns 200. I realize my response was not very helpful. It didn’t look like anyone was responding to your topic and I thought any response was better than none. The only other thing I can suggest is to try posting in the WooCommerce support forum. Maybe someone there has encountered this and can shed some light.

    Thread Starter vankampenp

    (@vankampenp)

    @bcworkz thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Rest API in IIS returns HTML (Object Moved) on post’ is closed to new replies.