Dears,
using the api integration, i am trying to insert a new product on shopify using the below code but it's giving this error The remote server returned an error: (400) Bad Request while getting the response
public static void main(Args args)
{
System.IO.Stream requestStream;
str url = "https://xxxx.myshopify.com/admin/api/2021-01/products.json";
str user = "xxxxxxxxxx";
str pass = "xxxxxxxxxxxxx";
str token,rawresponse;
List mylist = new List(Types::String);
mylist.addend("Barnes & Noble");
mylist.addend("Johns Fav");
mylist.addend("Big Air");
IS_ShopifyContract contract = new IS_ShopifyContract();
contract.ParmTitle('test 123');
contract.Parmbody_html('This is a test product');
contract.ParmVendor('abc');
contract.ParmProduct_type('Snowboard');
contract.ParmTags(mylist);
System.Text.Encoding encoding = System.Text.Encoding::UTF8;
System.Byte[] bytes = encoding.GetBytes(user ":" pass);
System.String base64 = System.Convert::ToBase64String(bytes);
var utf8 = System.Text.Encoding::get_UTF8();
str json = FormJsonSerializer::serializeClass(contract);
var bytes1 = utf8.GetBytes(json);
System.String headerKey = 'Authorization';
System.String headerValue = 'Basic ' base64;
System.Net.WebRequest request = System.Net.WebRequest::Create(url);
System.Net.WebHeaderCollection headers = request.Headers;
headers.Add(headerKey,headerValue);
request.set_method('POST');
request.ContentType='application/json';
requestStream = request.GetRequestStream();
requestStream.Write(bytes1, 0, bytes1.get_Length());
System.Net.WebResponse response = request.GetResponse();
System.IO.StreamReader reader = new System.IO.StreamReader(
response.GetResponseStream());
str wsResponse = reader.Readtoend();
info(wsResponse);
}