Have your say in Community Polls: What was/is your greatest motivation to start your own business?
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.

I am getting 406 error on adding product metafields using POST API. Please help!

I am getting 406 error on adding product metafields using POST API. Please help!

jinu1992
Visitor
1 0 0
function METAFIELD_UPDATE_TEST()

{
  var headers_test = 
    {
    "Content-Type" : "application/json",
    "Authorization""Basic " + Utilities.base64Encode(api_key + ":" + api_pass)
    };
  var product_id = 6648411324502;
  var dimensions = "lxbxh"
  var store_url'https://cubelelo-cube-store.myshopify.com/admin/2021-07/products/'+product_id+'/metafields.json';
  var post_dimensions= {"metafield":{"namespace":"my_fields","key":"dimensions","value":dimensions,"value_type":"string"}}
  
  var payload1 = JSON.stringify(post_dimensions);
  Logger.log(store_url);
  Logger.log(payload1);

  var params1 = {"method" : "PUT","headers" : headers_test,"contentType" : "application/json","payload" : payload1}
  var response1 = UrlFetchApp.fetch(store_urlparams1)
  
  Logger.log(response1.getContentText()) 

  return "UPDATED";
}
Replies 0 (0)