• Resolved pir81

    (@pir81)


    Hi

    I am trying to change a key-value pair in woocommerce using put in postman, but just cannot get ANY data to change.

    I know it works from our ERP system, where I just put the key and value in and it does its magic. But I want to learn and be able to test some other scenarios manually.

    1. I have set up the REST API consumer_key and consumer_secret in woo
    2. It is set to read AND write
    3. I can use a GET and get a correct reply with info
    4. Now I would like to PUT a specific meta_data field.
    5. I am on the correct server (checked the url) and I get Status 200ok, but nothing changes

    This is the reply from?GET?(just made it shorter)

       {
            "id": 123445,
            "name": "Productname",
            "meta_data": [
                {
                    "id": 121796,
                    "key": "_product_checkbox",
                    "value": "0"
                }
            ]
        }
    

    I want to change the value of?_product_checkbox, but even if I try just?name, I have no success.

    These are my PUT settings:

    staging102.ourdomain.com/wp-json/wc/v3/products/123445?consumer_key=ck_something&consumer_secret=cs_somethingelse
    

    and then I tried in Body > raw > JSON

    {"name":"Postmantest"}
    

    and also separately

    {
        "meta_data": [
            {
                "key": "_product_checkbox",
                "value": "1"
            }
        ]
    }
    

    It always returns with status 200 and ok, but there is just nothing at all happening. What am I doing wrong, what have I missed?

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter pir81

    (@pir81)

    No suggestions at all?

    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @pir81,

    It looks like you’re doing everything correctly. However, when using the PUT method in Postman, you must ensure that the request headers include “Content-Type: application/json”.

    Also, make sure that you are using the correct HTTP method. In your case, you should be using PUT, not POST.

    Another thing to consider is that you should use the complete URL in the PUT request, including the endpoint “/wp-json/wc/v3/products/123445”.

    If you’re still experiencing issues after trying these suggestions, we recommend asking development questions on the #developers channel of the WooCommerce Community Slack. Many of our developers hang out there and will be able to offer insights into your question.

    I wish I could help more, but hopefully, this gets you going in the right direction to get some further insight/information.

    Thread Starter pir81

    (@pir81)

    Hi Shameen,

    thank you for your reply

    • the header includes “Content-Type” application/json
    • I am using PUT (see inital post)
    • I am using the full string (see inital post)

    So I guess I have set up everyhting as it should be. Still something is wrong. I will try the Slack Channel. Thanks.

    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @pir81,

    I would suggest you to double-check the response body after making the PUT request. The updated product details should be returned in the response body, including the updated meta_data or name.

    If the response body doesn’t reflect your changes, there might be an issue with the specific product or your setup. To isolate the issue, you may try updating a different product or try making a PUT request using a different tool or method.

    If you’re still facing issues, I recommend asking development questions on the #developers channel of the WooCommerce Community Slack, as suggested earlier. Many of our developers hang out there and will be able to offer insights into your question.

    Please don’t hesitate to ask in case you need our assistance with anything else.

    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @pir81,

    I’m marking this topic as “resolved” due to recent inactivity. If more assistance is needed, feel free to post back here or open a new topic.

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘how to PUT in Postman to change Woo REST API meta_data’ is closed to new replies.