Shopify metafields.json API returning "Continue" even though no cookies are stored

Highlighted
New Member
14 0 0

Hello,

 

I am working on implementing the metafield.json API to assign a metafield to a product resource. Below is my URL, and request body.

 

https://{store}/admin/api/2019-10/products/#2031935684681/metafields.json

{
  "metafield": {
    "namespace": "productId",
    "key": "productId",
    "value": 25,
    "value_type": "string"
  }
}

I am using Postman to execute these requests, I saw other posts where others were instructed to clear the cookies before executing a POST request. I have done that but still receive this "Continue" response

 

<html>

<body>
	<noscript>
		<a
			href="https://app.shopify.com/services/login/identity?destination_uuid=836a1726-5bd4-4c97-8cfa-08cf8373bbbc&amp;merge_ignore_postponed=false&amp;prompt=merge&amp;return_to=https%3A%2F%2Fapp.shopify.com%2Fservices%2Flogin%2Fidentity_callback%3Ffrom_signup%3Dfalse%26locale%3Den%26shop_name%3DNutra%2BProducts%2BDirect%26state%3DKwwJRzgUakc1nXIfWWOc9rOQ0VCHl9EUs5bHvCXSSbjj9SlTwyxuYQ60vHWn5sRw1nUyh1HUK82qyuo8VUJMwHeKnGJLaUmp45aPJ97ArK8wuhFtWEJ9jK6CX9a7F5ByqgXcqzOjOAjzLWXAx-EYSyzIMyzIkWMqZoyjV7r4_n2XcOsc9LkftpIZ1QwUacgWEHen140zUBqTBpMrq2I3cWYxSdMBUIpaegVphjH9iSPT-8tBBstQuRnI_m9gdb5m&amp;ui_locales=en&amp;ux=shop">Continue</a>
	</noscript>

	<script type="text/javascript">
		window.location = "https:\/\/app.shopify.com\/services\/login\/identity?destination_uuid=836a1726-5bd4-4c97-8cfa-08cf8373bbbc\u0026merge_ignore_postponed=false\u0026prompt=merge\u0026return_to=https%3A%2F%2Fapp.shopify.com%2Fservices%2Flogin%2Fidentity_callback%3Ffrom_signup%3Dfalse%26locale%3Den%26shop_name%3DNutra%2BProducts%2BDirect%26state%3DKwwJRzgUakc1nXIfWWOc9rOQ0VCHl9EUs5bHvCXSSbjj9SlTwyxuYQ60vHWn5sRw1nUyh1HUK82qyuo8VUJMwHeKnGJLaUmp45aPJ97ArK8wuhFtWEJ9jK6CX9a7F5ByqgXcqzOjOAjzLWXAx-EYSyzIMyzIkWMqZoyjV7r4_n2XcOsc9LkftpIZ1QwUacgWEHen140zUBqTBpMrq2I3cWYxSdMBUIpaegVphjH9iSPT-8tBBstQuRnI_m9gdb5m\u0026ui_locales=en\u0026ux=shop";
	</script>
</body>

</html>

 

What am I doing incorrectly? Everything I've seen said clearing the cookies would work. Funny enough the POST request to retrieve a single metafield works just fine if I clear the cookies before, but for this one it still gives that result.

 

Any ideas????

0 Likes
Highlighted
Shopify Partner
40 1 4

There seems to be an issue with authentication. So either your credentials are not correct (obviously these are working as your single request went well) or the endpoint (link) is not addressed correctly. Try to remove the hash symbol (#) from your product-id.

0 Likes
Highlighted
New Member
14 0 0

Hey @leinaD,

 

Thank you for the reply, this actually seems to work and I will mark your reply as the solution. I do have one more question about the API if you might be able to help me out. This endpoint seems to create a metafield for a product, but do you know if there is a way to create a variant metafield via the API? Appreciate your time and response!

0 Likes
Highlighted
Shopify Partner
40 1 4

Sure Quinn, you can add Metafields to your variant as well. The endpoint is like this:

 

/admin/products/#{id}/variants/#{id}/metafields.json

I prefer to add variant related data to my product metafields. I use the products EAN as metafield namespace and can simply select e.g. shipping-time by writing this with liquid:

 

{{ product.metafields.1234567890123.shippingttime }}

You can as well have a look at the API reference, which is nicely done.

https://help.shopify.com/en/api/reference/metafield

 

 

0 Likes