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.

How to get all metafields despite if they have a value or not using Rest API

How to get all metafields despite if they have a value or not using Rest API

TestT1232
Visitor
2 0 0

I am trying to retrieve all metafields when the OwnerResource is set to 'Product', but the API only returns metafields that have a value. Metafields without a value are not included in the response.

 

Example:

Product 1:

  • metafield1 = 4
  • metafield2

Using the REST API, only metafield1 is returned. Metafield2 is not returned in response because it does not have a value.

 

Can you have a look at this?

Replies 3 (3)

Ahsan-ah-med
Shopify Partner
31 3 4

Can you explain where you use fetch API 

Ahsan Ahmed
Shopify Developer | 2 Years of Experience
Shopify App Developer | 1 Year Experience
I'm Build Custom App for Client Requirements Using Shopify Functions, Shopify Checkout Ui Extensions, Remix App,
Transforming Websites into Shopify
 Converting Existing Websites (WooCommerce, Figma, Magento, etc.) to Shopify
️ Developing Custom Shopify Apps for Unique Client Needs
 Enhancing Shopify Functions with Checkout Extensions for Plus Users
Let's Build Your Dream Store Together!
TestT1232
Visitor
2 0 0

I am using endpoints from shopify official documentation below.

 

Metafield (shopify.dev) 

Ahsan-ah-med
Shopify Partner
31 3 4

This is an admin API, and my question is: where do you use these endpoints, on the admin App or the storefront?

Ahsan Ahmed
Shopify Developer | 2 Years of Experience
Shopify App Developer | 1 Year Experience
I'm Build Custom App for Client Requirements Using Shopify Functions, Shopify Checkout Ui Extensions, Remix App,
Transforming Websites into Shopify
 Converting Existing Websites (WooCommerce, Figma, Magento, etc.) to Shopify
️ Developing Custom Shopify Apps for Unique Client Needs
 Enhancing Shopify Functions with Checkout Extensions for Plus Users
Let's Build Your Dream Store Together!