How to retrieve and update custom field via API (shop_coupon)

Support MB REST API How to retrieve and update custom field via API (shop_coupon)

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #36334
    komozuro@gmail.com[email protected]
    Participant

    Hi,

    I created some custom fields for Woocommerce Coupon post type (shop_coupon)
    Now I want to retrieve & update those fields via API calls
    How could I do that?

    Many Thanks

    #36338
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Please follow this documentation to know how to update the field value via WP Rest API https://docs.metabox.io/extensions/mb-rest-api/

    #36343
    komozuro@gmail.com[email protected]
    Participant

    Yes, I follow that post but got the response:

    {
        "code": "rest_post_invalid_id",
        "message": "Invalid post ID.",
        "data": {
            "status": 404
        }
    }

    (Note: the post type is shop_coupon not single post, terms, single term, users, single user)
    How to solve it?

    #36344
    komozuro@gmail.com[email protected]
    Participant

    404 error when I using endpoint: /wp-json/wp/v2/posts/{post_id} or /wp-json/wp/v2/coupons/{post_id}
    200 OK with endpoint: /wp-json/wc/v3/coupons/{post_id} BUT NOTHING HAPPEN, field not updated

    #36347
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Thanks for your additional information.

    WooCommerce has its own REST API schema so it might not work with the field created by Meta Box. You can contact WooCommerce support to ask for help with this case.

    If you want to use the REST API v2 of WooCommerce, please follow this documentation https://woocommerce.github.io/woocommerce-rest-api-docs/v2.html#requests-responses

    Endpoint format: https://www.example.com/wc-api/v2/coupons?consumer_key=123&consumer_secret=abc

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