• Resolved garrq

    (@garrq)


    Hi CPT UI Team,

    Good day. I’m having trouble with creating a New Custom Post Type via Postman. I’m receiving this error, please see below.

    I followed the WP-API how to GET the custom post type and it was a success. However, when I’m trying to Create a POST I always got this error.

    {
    “code”: “rest_cannot_create”,
    “message”: “Sorry, you are not allowed to create posts as this user.”,
    “data”: {
    “status”: 401
    }
    }

    Any Idea bout this issue?. Also, I’m using Basic Authentication and I have Editor Role.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Are you talking about creating a post in a given post type? or are you trying to register a new post type in CPTUI using a REST API request?

    Otherwise the error message basically outlines why you’re not succeeding, some aspect of the user being used isn’t allowed to create new posts. Also, even though you may have an editor user associated with you, doesn’t mean that the request being sent by Postman does. That may be getting viewed as an unauthenticated user and thus rejected.

    What parameters are you sending with the request?

    Thread Starter garrq

    (@garrq)

    Thank you for your reply. I’m talking about creating a post in a given post type. Please see this image link – https://imgur.com/a/YizWmHf.

    I also double-check the capabilities that is should have “create post” and “create gqapi” in Editor Role.

    Do you have any reference to do a proper Create Post (Custom Post Type) using Postman?

    Thank you in advance Michael.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Perhaps something like https://rudrastyh.com/wordpress/rest-api-create-delete-posts.html will help outline parts of what is being needed. For example, is wpapi your WordPress user or something for like an htpasswd prompt?

    Beyond that, I haven’t had much experience with creating content via the REST API and this really isn’t anything specific to CPTUI itself.

    Thread Starter garrq

    (@garrq)

    Okay I’ll try also this link and use this as the basis but the example isn’t a custom post type though. wpapi is the username and it has editor role.

    Okay then, I’ll run my tests first and then share the result.

    Thank you Michael.

    Thread Starter garrq

    (@garrq)

    Hi,

    Just an update. I solved the problem by uninstalling different authorization plugins and install a fresh one. Somehow it messed up the authentication of WP-API.

    Thanks.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Interesting, but glad you got something working here.

    Thanks for the followup.

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

The topic ‘Use Postman to Create Custom Post Type’ is closed to new replies.