Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

list.single_line_text_field Post?

list.single_line_text_field Post?

Chris_Sydney
Shopify Partner
117 4 24

Hey There, 

 

Wondering if anyone has any guidance... I am sending the below payload to the following URL, but seem to be getting a bad request error. namespace and key are correct, as it the type.

https://{{store_name}}.myshopify.com/admin/api/{{api_version}}/variants/{{variant_id}}/metafields.json

 

{
        "metafield": {
            "namespace": "theme",
            "key": "highlight",
            "value": ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
            "type": "list.single_line_text_field"
        }
}

 

 

Replies 5 (5)

SBD_
Shopify Staff
1831 273 423

Hey @Chris_Sydney 

 

I think the payload has to include the variant ID, e.g.:

 

{"variant":
  {
    "id":808950810,
    "metafields": [
      {"key":"new","value":"newvalue", etc.. }
    ]
  }
}

 

More here: https://shopify.dev/docs/api/admin-rest/2023-07/resources/product-variant#put-variants-variant-id

 

Let me know if you get stuck!

Scott | Developer Advocate @ Shopify 

Deepaksharma023
Shopify Partner
5 0 0

{{ "metafield": { "namespace": "theme", "key": "highlight", "value": "[\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\"]", "type": "list.single_line_text_field" } }
 
Chris_Sydney
Shopify Partner
117 4 24

thanks, yeah I kind of landing on this, I need to write the payload before it sent via the admin API.

Deepaksharma023
Shopify Partner
5 0 0
--header 'x-shopify-access-token: c422350d7c54ea0ef161ebb656test' \
--header 'Content-Type: application/json' \
--data-raw '{
"metafield": {
"namespace": "test_namespace",
"key": "test_key",
"value": "[\"111\",\"222\",\"333\",\"444\",\"555\"]",
"type": "list.single_line_text_field"
}
}'

 

Deepaksharma023
Shopify Partner
5 0 0

With the given curl command, you can invoke the admin API.