Failed to update customer tags by Admin REST API

I’m trying to update a customer’s tags by sending A PUT request.

BUT I always get this response : {“errors”:{“customer”:“Required parameter missing or invalid”}}

Thanks for Help!!!

<>

req_url = "https://myshop.co/admin/api/2022-10/customers/123456789.json"

req_headers = {
    "X-Shopify-Access-Token": "XXXX",
    "Content-Type": "application/json"
}
req_body = {
    "customer": {
        "id": 123456789,
        "tags": "test1,test2"
    }
}
req = requests.put(req_url, headers=req_headers, json=req_body)
print(req.json())

{“errors”:{“customer”:“Required parameter missing or invalid”}}

this is x-request-id from my response header :

329c4c02-deeb-4385-bd2d-ad3f13230110

thanks!!

Hi @Gmistyle :waving_hand:

Would you please try it in the below curl request instead:

curl -L -X PUT 'https://{SHOP_NAME}.myshopify.com/admin/api/2023-01/customers/123.json' \
-H 'X-Shopify-Access-Token: {ADMIN_TOKEN}' \
-H 'Content-Type: application/json' \
-d '{"customer": {"id": "123", "tags": "abc,def"}}'

If that works for you, it’s likely an issue with your python implementation. You may need to just encode the payload in a dict and pass it as data in your put request like this:

url = f"https://{SHOP_NAME}/admin/api/2023-01/customers/123.json"
data = {
    "customer": {
        "id": 123,
        "tags": "abc,def"
    }
}
data = json.dumps(data)
req = requests.put(url, headers=headers, data=data)

Hope that helps!

Thanks for your reply,

I haven’t tried with curl put request.

But I have tried many ways to send the payload like below:

1.) requests.put(…, data=json.dumps(dict_payload))

2.) requests.put(…, data=json.dumps(dict_payload).encode('utf-8))

3.) requests.put(…, data=json.dumps(dict_payload).encode())

4.) requests.put(…, json=dict_payload)

unfortunately, it all failed, here is the x-request-id which sent payload like you suggest:

X-Request-ID : 64f807ea-87fe-4bc2-bef8-98b2744b539b

I also tried to send request by urllib3, the same result.

is this possible to be caused by like…wrong configuration in Shopify APP & Dev setting?

I tried in curl request and I get the same result : {“errors”:{“customer”:“Required parameter missing or invalid”}}

The logs show that your put request doesn’t contain a payload. Are you ensuring that your curl request payload is properly formatted as shown in the below example?

1 Like

Thanks, Here are my screenshot from curl request and python request.

I found the last screenshot I offered contained a typo with customer’s’, here is a correct one.

from your answer, it seems that shopify admin API somehow didn’t get my payload. Besides, I use postman to send this requests with the same value. I get a status 200 response, but nothing changed.

I finally solved it. The idea was found from here: https://community.shopify.com/c/shopify-apis-and-sdks/python-product-tag-update-400-error-product-required-parameter/m-p/1951780

To everyone have the same problem : try every shop domain you can find from your shopify admin