Trying to update a CPT meta field and getting a 401

Support MB REST API Trying to update a CPT meta field and getting a 401

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #31135
    Jim HunterJim Hunter
    Participant

    I need to update a 'last_viewed' field via REST and am following the convention of /wp/v2/category_sponsor/1141 then passing in a JSON data packet like:
    { "meta_box": { "last_viewed" : "current date/time"}}
    But I am getting a response from the server of:

    {
    "code": "rest_cannot_edit",
    "message": "Sorry, you are not allowed to edit this post.",
    "data": {
    "status": 401
    }
    }

    I am not going to include login authentication info because this is in JavaScript in the client browser, so is there a setting I can change to allow non-authenticated CPT updates via REST API?

    I had my own API for this before I moved to MB, so I wanted to do it the MB way. If it's not possible, I can go back to using my own code for posting back.

    Thanks,
    jim

    #31140
    Long NguyenLong Nguyen
    Moderator

    Hi,

    It's very dangerous if you disable the authentication of WP REST API because anyone can manipulate data on your site. MB REST API does not support an option/setting to turn it off. If you do in a testing site, please refer to this topic https://github.com/WP-API/WP-API/issues/1924

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.