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

jinu1992
New Member
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)