Retrieving Product metafields returns Shop metafields

StephCoder
New Member
2 0 0

Hello,

 

There's definitely something wrong with the Metafields API unless I missed some recent changes. I'm just trying to get a list of meta fields for a specific product.  I was surprised to see it returns 'shop' meta field instead. I also tried adding a 'product' meta field and received an existing 'shop' meta field in the response.

 

Here are the request details (with hidden sensitive data):

 

 

REQUEST URI:
{
  pathname: '/admin/api/2021-10/metafields.json',
  hostname: '*****.myshopify.com',
  protocol: 'https:',
  search: '?owner_id=******&owner_resource=product'
}

REQUEST OPTIONS:
{
  "headers": {
    "User-Agent": "shopify-api-node/3.8.0",
    "Authorization": "Basic ****************"
  },
  "timeout": 60000,
  "responseType": "json",
  "retry": 0,
  "method": "GET"
}

RESPONSE BODY {
  metafields: [
    {
      id: ****,
      namespace: '***',
      key: 'google_analytics_id',
      value: '****',
      value_type: 'string',
      description: null,
      owner_id: *****,
      created_at: '2021-11-07T20:27:42+00:00',
      updated_at: '2021-11-07T20:27:42+00:00',
      owner_resource: 'shop',
      type: 'single_line_text_field',
      admin_graphql_api_id: 'gid://shopify/Metafield/****'
    },
    {
      id: *****,
      namespace: '*****',
      key: 'rings',
      value: '{"fmrs_enabled":1,"sizes":[4,5,6,7,8,9,10,11,12,13]}',
      value_type: 'json_string',
      description: null,
      owner_id: ******,
      created_at: '2021-11-07T20:27:43+00:00',
      updated_at: '2021-11-07T20:27:43+00:00',
      owner_resource: 'shop',
      type: 'json',
      admin_graphql_api_id: 'gid://shopify/Metafield/******'
    }
  ]
}

 

 

Any idea why it may happen?

 

 

Reply 1 (1)
StephCoder
New Member
2 0 0

I encapsulated the metafield object inside a metafield key to fix this error. What is strange is the API doesn't return any error but instead show random metafields.