A developer is encountering a 406 Not Acceptable error when attempting to POST metafield values to a predefined metafield (“gender” under namespace “my_fields”) via Shopify’s API. The same POST request succeeds when targeting undefined metafields, though these only appear in the unstructured section.
Key Issue:
Defined metafield “gender” rejects POST requests
GET requests return no results (likely because no values exist yet)
Undefined metafields accept POST requests without error
Suggested Solutions:
Verify data type matching – Ensure the value format (string, integer, list) matches the defined metafield’s type in Shopify
Use PUT instead of POST – PUT updates existing defined metafields, while POST creates new ones
Confirm API targeting – Double-check product ID and namespace in requests
Manually initialize the metafield – Set an initial value in Shopify admin to make it retrievable via GET, then update using PUT with the metafield ID
Check API permissions – Verify write_products and write_metafields scopes are enabled
The discussion remains open with the original poster yet to confirm resolution.
Summarized with AI on October 31.
AI used: claude-sonnet-4-5-20250929.
I am using Shopifys API to succesfully create new products on Shopify. I am trying to add a step in the workflow to also add the metafields for the product.
The metafields have the namespace “my_fields”.
As an example, I have a metafield with the key: “gender”. If I use the POST API to add the value “mens” to this metafield I get this error: “Webhook HTTP request failed with exception The remote server returned an error: (406) Not Acceptable.”
The metafield “gender” is already defined in my shopify store. If I run the exact same POST request to a an undefined metafield, i.e. “gendering” for example, the request is successful and I can see the metafield has been added, although does only show in the unstructured metafields section.
I’m sure i’m just missing something here, but why can’t I successfully POST the metafield value to a defined metafield such as “gender”?
I thought that maybe I needed to use a PUT request with the metafield ID for gender, but when I ran a GET request it came back with no results. I’m assuming because none of the metafields for this product have any values yet.
Sounds like the issue is related to Shopify’s validation rules for defined metafields Since “gender” is a predefined metafield, it expects the correct format and type. Here are a few things to check:
Check the metafield type – Ensure the data type you are sending (string, integer, list, etc.) matches the defined metafield type in Shopify. A mismatch can cause a 406 Not Acceptable error.
Use PUT for updates – If the metafield is already defined but has no value, you likely need to use a PUT request instead of POST. A POST request creates a new metafield, whereas a PUT updates an existing one.
Ensure you are targeting the correct resource – Since your GET request returns no results, verify you are querying the correct product ID and namespace (my_fields).
Manually add a value in Shopify first – If the metafield is defined but has never been used, Shopify might not return it via API. Try setting a value manually in Shopify, then run a GET request to find its metafield ID and update it using PUT.
Check API permissions – Ensure your API has write_products and write_metafields permissions, as Shopify restricts certain actions based on API scope.
If all else fails, try creating a new defined metafield with a different key and test if the issue persists