API Metafield character limits

Highlighted
Tourist
4 0 1

We are receiving the following error when attempting to upload a product with attached request.

It seems that there is a character limit of 164 characters in this meta-field. If that is true, we would be unable to upload the spec tables html etc as a metafield and would need another approach. Also, I am really not seeing this limit documented anywhere.

 

Error message

 

400 {"error":"783: unexpected token at '{\"product\":{\"title\":\"BERTAZZONIt_HERT486GDFSNET_48 inch Dual Fuel Range, 6 Brass Burners and Griddle, Electric Self Clean Oven Nero Matt\",\"product_type\":\"GAS RANGES\",\"vendor\":\"BERTAZZONIt\",\"metafields_global_description_tag\":\"BERTAZZONIt_HERT486GDFSNET_48 inch Dual Fuel Range, 6 Brass Burners and Griddle, Electric Self Clean Oven Nero Matt_PROFESSIONAL GAS RANGE\",\"metafields_global_title_tag\":\"BERTAZZONIt_HERT486GDFSNET_PROFESSIONAL GAS RANGE|Town Appliance\",\"body_html\":\"\u003cstrong\u003eShlomo TEST PRODUCT  8-13-2020!\u003c\/strong\u003e\",\"metafields\":[{\"key\":\"Other\",\"value\":\"O\",\"namespace\":\"Color\",\"value_type\":\"string\"},{\"key\":\"Stainless Steel\",\"value\":\"S\",\"namespace\":\"Color\",\"value_type\":\"string\"},{\"key\":\"dimensions\",\"value\":\"48\\\" 34 3\/4 27 3\/8\",\"namespace\":\"Dimension\",\"value_type\":\"string\"},{\"key\":\"spec_table_html\",\"value\":\"\u003ctable  class='inline_sd_table'\u003e\u003ctr class='inline_sd_cell_row'\u003e     \u003ctd class='inline_sd_even_cell'\u003e\u003cb\u003eSize\u003c\/b\u003e\u003c\/td\u003e     \u003ctd class='inline_sd_even_cell'\u003e48 in\u003c\/td\",\"namespace\":\"specification\",\"value_type\":\"string\"},{\"key\":\"map_price\",\"description\":\"map_price\",\"value\":\"12599.0\",\"namespace\":\"map_price\",\"value_type\":\"string\"},{\"key\":\"msrp\",\"description\":\"msrp\",\"value\":\"16380.0\",\"namespace\":\"msrp\",\"value_type\":\"string\"},{\"key\":\"barcode\",\"description\":\"barcode\",\"value\":\"$9,828\",\"namespace\":\"barcode\",\"value_type\":\"string\"},{\"key\":\"in_cart_price\",\"description\":\"in_cart_price\",\"value\":\"12599.0\",\"namespace\":\"in_cart_price\",\"value_type\":\"string\"},{\"key\":\"Bertazzoni Suite Deals Rebate\",\"value\":\"Save on qualifying Bertazzoni Ventilation and Dishwashers with purchase of qualifying Bertazzoni Kitchen Appliances.\",\"namespace\":\"TownApplianceAPI\",\"value_type\":\"string\"},{\"key\":\"Bertazzoni Range Promo\",\"value\":\"Receive up to a $600 Instant Rebate with purchase of a qualifying Bertazzoni range.\",\"namespace\":\"TownApplianceAPI\",\"value_type\":\"string\"}],\"variants\":[{\"sku\": \"HERT486GDFSNET\",\"compare_at_price\": \"15000\",\"barcode\": \"\",\"weight\": 0.00,\"price\": 10000}],\"tags\":\"BER,GR,GASPRO\"}'"}

 

request:

 

{
"product":{
"title":"BERTAZZONIt_HERT486GDFSNET_48 inch Dual Fuel Range, 6 Brass Burners and Griddle, Electric Self Clean Oven Nero Matt",
"product_type":"GAS RANGES",
"vendor":"BERTAZZONIt",
"metafields_global_description_tag":"BERTAZZONIt_HERT486GDFSNET_48 inch Dual Fuel Range, 6 Brass Burners and Griddle, Electric Self Clean Oven Nero Matt_PROFESSIONAL GAS RANGE",
"metafields_global_title_tag":"BERTAZZONIt_HERT486GDFSNET_PROFESSIONAL GAS RANGE|Town Appliance",
"body_html":"<strong>Shlomo TEST PRODUCT 8-13-2020!</strong>",
"metafields":[
{
"key":"Other",
"value":"O",
"namespace":"Color",
"value_type":"string"
},
{
"key":"Stainless Steel",
"value":"S",
"namespace":"Color",
"value_type":"string"
},
{
"key":"dimensions",
"value":"48\" 34 3/4 27 3/8",
"namespace":"Dimension",
"value_type":"string"
},
{
"key":"spec_table_html",
"value":"<table class='inline_sd_table'><tr class='inline_sd_cell_row'> <td class='inline_sd_even_cell'><b>Size</b></td> <td class='inline_sd_even_cell'>48 in</td",
"namespace":"specification",
"value_type":"string"
},
{
"key":"map_price",
"description":"map_price",
"value":"12599.0",
"namespace":"map_price",
"value_type":"string"
},
{
"key":"msrp",
"description":"msrp",
"value":"16380.0",
"namespace":"msrp",
"value_type":"string"
},
{
"key":"barcode",
"description":"barcode",
"value":"$9,828",
"namespace":"barcode",
"value_type":"string"
},
{
"key":"in_cart_price",
"description":"in_cart_price",
"value":"12599.0",
"namespace":"in_cart_price",
"value_type":"string"
},
{
"key":"Bertazzoni Suite Deals Rebate",
"value":"Save on qualifying Bertazzoni Ventilation and Dishwashers with purchase of qualifying Bertazzoni Kitchen Appliances.",
"namespace":"TownApplianceAPI",
"value_type":"string"
},
{
"key":"Bertazzoni Range Promo",
"value":"Receive up to a $600 Instant Rebate with purchase of a qualifying Bertazzoni range.",
"namespace":"TownApplianceAPI",
"value_type":"string"
}
],
"variants":[
{
"sku":"HERT486GDFSNET",
"compare_at_price":"15000",
"barcode":"",
"weight":0.00,
"price":10000
}
],
"tags":"BER,GR,GASPRO"
}
}

0 Likes
Highlighted
Shopify Expert
9933 106 1767

A general metafield has a limit of 65535 chars but ignoring that, the error you're seeing looks more due to malformed data being sent in the request.

Does the request work without the metafield?

I've not tested it (and you can as well by just posting a metafield directly to the metafield endpoint) but would expect that both the meta title and meta description fields to have a much smaller limit given they are special fields.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Highlighted
Tourist
4 0 1
the request works both without the metafield and also with the metafiled limited to 164 characters in the value. We've also replaced the HTML with simple characters (165 X's which also errored). The problematic token is below, please confirm if this is considered a special field.

{
"key":"spec_table_html",
"value":" "namespace":"specification",
"value_type":"string"
}
Size48 in
0 Likes
Highlighted
Shopify Partner
539 39 110

For grins I tried creating a new product with a 164-character metafield value and one with a 165-character metafield value. Both of them worked. Weird...

164.jpg165.jpg

0 Likes
Highlighted
Tourist
4 0 1
Can you maybe assist with what’s going on by me. Is my format wrong.
0 Likes
Highlighted
Shopify Partner
539 39 110

I simplified a mock-up of your mutation in my GraphiQL app on my test store. The metafields referenced exactly as you described worked. See below. Are you using raw GQL or a third-party library that manages the API calls? Maybe if it's the latter it's an issue there with things being mangled somehow?

POST https://shopify-graphiql-app.shopifycloud.com/admin/api/2020-07/graphql HTTP/1.1
Host: shopify-graphiql-app.shopifycloud.com
Connection: keep-alive
Content-Length: 1657
X-GraphQL-Cost-Include-Fields: false
X-CSRF-Token: uEZEWvz/RnqWE2m+9u926NICpO+DS7rTdDelkl7H+XHTVko05RAEnEX4oU14SCL1CPan9Z02zcmRXdXLINmdTA==
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36
Content-Type: application/json
Accept: */*
Origin: https://shopify-graphiql-app.shopifycloud.com
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9

{
   "query":"mutation productCreate($product: ProductInput!) {\n  productCreate(input: $product) {\n    product {\n      id\n      title\n    }\n  }\n}\n",
   "variables":{
      "product":{
         "title":"BERTAZZONIt_HERT486GDFSNET_48 inch Dual Fuel Range, 6 Brass Burners and Griddle, Electric Self Clean Oven Nero Matt",
         "metafields":[
            {
               "key":"Other",
               "value":"O",
               "namespace":"Color",
               "valueType":"STRING"
            },
            {
               "key":"Stainless Steel",
               "value":"S",
               "namespace":"Color",
               "valueType":"STRING"
            },
            {
               "key":"dimensions",
               "value":"48\" 34 3/4 27 3/8",
               "namespace":"Dimension",
               "valueType":"STRING"
            },
            {
               "key":"spec_table_html",
               "value":"<table class='inline_sd_table'><tr class='inline_sd_cell_row'> <td class='inline_sd_even_cell'><b>Size</b></td> <td class='inline_sd_even_cell'>48 in</td",
               "namespace":"specification",
               "valueType":"STRING"
            },
            {
               "key":"map_price",
               "description":"map_price",
               "value":"12599.0",
               "namespace":"map_price",
               "valueType":"STRING"
            },
            {
               "key":"msrp",
               "description":"msrp",
               "value":"16380.0",
               "namespace":"msrp",
               "valueType":"STRING"
            },
            {
               "key":"barcode",
               "description":"barcode",
               "value":"$9,828",
               "namespace":"barcode",
               "valueType":"STRING"
            },
            {
               "key":"in_cart_price",
               "description":"in_cart_price",
               "value":"12599.0",
               "namespace":"in_cart_price",
               "valueType":"STRING"
            },
            {
               "key":"Bertazzoni Suite Deals Rebate",
               "value":"Save on qualifying Bertazzoni Ventilation and Dishwashers with purchase of qualifying Bertazzoni Kitchen Appliances.",
               "namespace":"TownApplianceAPI",
               "valueType":"STRING"
            },
            {
               "key":"Bertazzoni Range Promo",
               "value":"Receive up to a $600 Instant Rebate with purchase of a qualifying Bertazzoni range.",
               "namespace":"TownApplianceAPI",
               "valueType":"STRING"
            }
         ]
      }
   },
   "operationName":"productCreate"
}

HTTP/1.1 200 OK
Date: Thu, 27 Aug 2020 15:49:09 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Vary: Accept-Encoding
X-Upstream-Request-ID: e9ece7a7-851a-4e80-9c60-65f47499830c
P3P: CP="Not used"
ETag: W/"6fa1fabeb79994274edd2b61e277a548"
Cache-Control: max-age=0, private, must-revalidate
X-Request-Id: bd38b61a45780a17235c66b176d7b9ad
X-Runtime: 0.761445
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
X-Download-Options: noopen
X-Permitted-Cross-Domain-Policies: none
Referrer-Policy: origin-when-cross-origin
Content-Security-Policy: default-src 'self'; frame-ancestors diamond-cellar.myshopify.com; object-src 'none'; script-src 'self' sdks.shopifycdn.com cdn.shopify.com 'unsafe-inline' 'unsafe-eval'; style-src 'self' sdks.shopifycdn.com cdn.shopify.com; upgrade-insecure-requests
Server-Timing: processing;dur=763, socket_queue;dur=1.056, edge;dur=2.125
X-Dc: gke
Content-Length: 371

{
   "data":{
      "productCreate":{
         "product":{
            "id":"gid:\/\/shopify\/Product\/5644748325026",
            "title":"BERTAZZONIt_HERT486GDFSNET_48 inch Dual Fuel Range, 6 Brass Burners and Griddle, Electric Self Clean Oven Nero Matt"
         }
      }
   },
   "extensions":{
      "cost":{
         "requestedQueryCost":10,
         "actualQueryCost":10,
         "throttleStatus":{
            "maximumAvailable":1000.0,
            "currentlyAvailable":990,
            "restoreRate":50.0
         }
      }
   }
}
0 Likes