I am trying to retrieve metafields for multiple products via this REST Admin API call: https://shopify.dev/docs/api/admin-rest/2024-01/resources/metafield#get-metafields
However I can’t seem to figure out how to send multiple metafield[owner_id]s in a single request. The reference documention states the following:
Retrieve a list of metafields by using query parameters> Retrieves a list of metafields that belong to a resource by using query parameters.> > Parameters> api_version: string - required> metafield[owner_id] ≤ 100 (Filter by the resource ID on which the metafield is attached to.)> metafield[owner_resource] ≤ 100 (Filter by the resource name on which the metafield is attached to.)
The above is clearly specifying that it is possible to request up to 100 different resource ID’s in a single request (the “≤ 100” part). Unfortunately there is no example of how to do it and I can’t find any other examples.
My first attempt was using commas to separate multiple ID’s, like so:
x.myshopify.com/admin/api/2023-10/metafields.json?metafield[owner_id]=ID1,ID2&metafield[owner_resource]=product
This pattern is used elsewhere in the API, but does not work here. It simply responds with a 400 error stating “expected String to be a id”. (Note: I did us actual product ID’s and not just the ID1,ID2). I also tried modifying this by also adding another product to metafield[owner_resource] since I figured maybe they needed to line up pairwise with the ID’s, like so:
x.myshopify.com/admin/api/2023-10/metafields.json?metafield[owner_id]=ID1,ID2&metafield[owner_resource]=product,product
Still that didn’t work. I tried different kinds of separators (+,|,&) for separing the ID’s, but nothing worked. I tried repeating the query parameter for each ID, like so:
x.myshopify.com/admin/api/2023-10/metafields.json?metafield[owner_id]=ID1&metafield[owner_id]=ID2&metafield[owner_resource]=product
However nothing seems to work for me.
I’d appreciate if anyone can help me with this or if they can tell me if the reference documentation is just incorrect when it says “≤ 100” metafield owner id’s can be sent. Thank you in advance!