Shopify_api GEM Retrieving product metafield JSON_STRING only returns first pair

Hi all –

I have a test store, where I am trying to retrieve the full JSON_STRING metafield (purpose is to produce timed promotional notes using product metafields). I am trying to in this case update the values of the product metafield to remove part but not all of the JSON_STRING value.

The actual metafield value seen in: https://MYSTESTSTORE.myshopify.com/admin/products/1357318553659/metafields.json is:

{"metafields":[{"id":21049361170610,"namespace":"promo_code","key":"time_content","value":"[{\"collection_id\":\"57783975995\",\"promo_start\":\"2021-12-05T15:08\",\"promo_end\":\"2021-12-20T15:08\",\"promo_text\":\"Main Promo Text\",\"promo_cond_text\":\"Cond Promo text\"},{\"promo_start\":\"2022-01-02T16:08\",\"promo_end\":\"2022-01-06T16:08\",\"promo_text\":\"Main Promo Text1\",\"promo_cond_text\":\"Cond Text 1\"}]","value_type":"json_string","description":"time and content for promo code","owner_id":1357318553659,"created_at":"2021-12-13T15:08:53-08:00","updated_at":"2021-12-13T16:09:09-08:00","owner_resource":"product","admin_graphql_api_id":"gid:\/\/shopify\/Metafield\/21049361170610"}]}

However, when I use the following Ruby Code using the latest gem / api version I get different results than using the browser:

Code:

shopname = ENV[‘SHOPIFY_SHOP_NAME’]
api_key = ENV[‘SHOPIFY_API_KEY’]
password = ENV[‘SHOPIFY_API_PASSWORD’]
shop_url = [email removed]
ShopifyAPI::Base.site = shop_url
ShopifyAPI::Base.api_version = ‘2021-07’
ShopifyAPI::Base.timeout = 180

temp_meta_shopify = ShopifyAPI::Metafield.all(params: {resource: ‘products’, resource_id: mmt.product_id, namespace: ‘promo_code’, fields: ‘value’})
puts “----”
puts temp_meta_shopify.inspect
puts “**************”

And here is the relevant output:

[#<ShopifyAPI::Metafield:0x00007f92898135d0 [email removed] Promo Text","promo_cond_text":"Cond Promo text"}]”}, [email removed] :resource_id=>1357314457659}, [email removed]


From the above Web URL, I should get:

“[{"collection_id":"57783975995","promo_start":"2021-12-05T15:08","promo_end":"2021-12-20T15:08","promo_text":"Main Promo Text","promo_cond_text":"Cond Promo text"},{"promo_start":"2022-01-02T16:08","promo_end":"2022-01-06T16:08","promo_text":"Main Promo Text1","promo_cond_text":"Cond Text 1"}]”

So why is my second JSON pair inside the array not returning? Is there a parameter I need to include regarding length or some other aspect when calling the value and its JSON_STRING ?

This is a plain old ruby script so there is nothing special about it. Is this broken in the REST API? Do I need to use the GraphQL to get the data? [I prefer the REST API because its just so easy to update.]

Background, if you can update the Shopify products you can have via Liquid timed promo notes using today’s date (just convert to UNIX time) including flash promos from say 9 am to noon on a particular day.

Many thanks for any help!