Issue: Attempts to add a product metafield via the Shopify Admin API return HTTP 406, while a GET on the same product succeeds. Endpoint used: /admin/api/2019-07/products/{product_id}/metafields.json.
Context: 406 Not Acceptable typically indicates the server can’t return a response in the requested format. The requester shared full headers and body showing a PUT with Basic Auth and a Storefront access token header present. The body structure varies between attempts (a single metafields object vs. a product object containing a metafields array).
Key details from request:
Method: PUT
Headers include X-Shopify-Storefront-Access-Token and Basic Auth.
Body example nests metafields under product, e.g., key/value/value_type/namespace.
Latest guidance: A responder suggested using POST instead of PUT for creating metafields on a product. Another asked for full headers to diagnose format issues.
Status: No confirmed resolution from the original poster. Open questions include whether switching to POST resolves the 406 and whether header/content-type/accept expectations or payload structure are causing the error.
Notes: The exact request payload and headers are central to understanding the issue.
Can you share the full request with headers you are sending? 406 often means we can’t return the results in the format you are requesting. Chances are it’s an easy fix, but I’ll need some more info. Thanks!