• Hi John,

    I’m trying to debug a custom endpoint by doing a POST request, as an authenticated superadmin with an application password. I tried the first method with _wpnonce in the request URL, but I got an error “rest_cookie_invalid_nonce”
    With the app password, the request is successful but I don’t receive any QM data, the plugin is active and I can see the output in the admin with this user.

    Any ideas? Does the endpoint callback have to send back a specific type? I’ve tried new WP_REST_Response and an array.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    Hi Paul!

    If you’re sending a valid application password then you don’t also need a nonce for authentication.

    Are you performing an enveloped request? That’s the main thing that’s needed to see the full output otherwise you’ll only see an overview in the HTTP response headers.

    Have you read through https://querymonitor.com/wordpress-debugging/rest-api-requests/ ?

    Thread Starter Paul de Wouters

    (@pauldewouters)

    Thanks for replying so fast! 🙂

    I’m not sure why, I’m making a request from VS Code thunderclient – and this works fine https://mysite.local/wp-json/wp/v2/users?context=edit but I don’t get any QM headers or data in the response. I do see them if I open the rest api endpoint in the browser while logged in to the site

    Jason

    (@galapogos01)

    Hey Paul did you resolve this?

    I too am using an external client (curl in my case) and can not work out how to get QM to include results. I am trying to hit the WooCommerce API.

    The QM documentation uses WP specific buzzwords and I am having trouble understanding what is expected. For example when I visit /wp-admin/admin-ajax.php?action=rest-nonce I get a response of 0, not a nonce I can use.

    • This reply was modified 1 year, 7 months ago by Jason.
    Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    I’ve seen this reported a few times now and it seems that QM might not output its data when using an application password. It works as expected if you use regular authentication cookies plus a nonce. I will be looking into this properly soon.

    I can confirm that QM does not output data to wp-json responses when provided an application password, but it does work properly when you us WP Nonces.

    The QM documentation could be improved here, it says:

    This usually means including a valid _wpnonce parameter in the URL, the value of which you can get by visiting wp-admin/admin-ajax.php?action=rest-nonce

    https://querymonitor.com/wordpress-debugging/rest-api-requests/

    But it fails to mention that you also have to include in the headers the cookie that authenticates the user that generated the nonce.

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

The topic ‘REST API Requests no QM data’ is closed to new replies.