Using Api to Put Product on Shopify Generating Error 400 Bad Request

this-is-my-new-
New Member
1 0 0

 I am Trying to list Product on Shopify Using Web API 

 

 

 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url + "products.json");
                request.Credentials = new NetworkCredential(username, password);
                request.KeepAlive = false;
                request.ProtocolVersion = HttpVersion.Version11;
                request.Method = "POST";
                byte[] postBytes = Encoding.UTF8.GetBytes(jsonstring);
                request.ContentType = "application/json; charset=UTF-8";
                request.Accept = "application/json";
                request.ContentLength = postBytes.Length;
                Stream requestStream = request.GetRequestStream();
                requestStream.Write(postBytes, 0, postBytes.Length);
                requestStream.Close();
                HttpWebResponse response = null;
                try
                {
                    response = (HttpWebResponse)request.GetResponse();
                }
                catch (Exception a)
                {
                    Console.WriteLine(a.ToString());
                }

 

 

 

The Request I am Sending to List Product is in Json Format That is this 

 

 

{"product":{"title":"OPI FULL BLACK CORDED GAMING MOUSE 789","body_html":" Here testing item, here some features 
 ","product_type":"","vendor":"Please Select Vendor","tags":"","status":"active" ,"taxable":"true","options":[],"images":[
  {
    "src": "https://business.tradingzon.com/images/itemimages/15Json Turneryg2 (151).jpg"
  },
  {
    "src": "https://business.tradingzon.com/images/itemimages/15Json Turneryg1 (253).jpg"
  },
  {
    "src": "https://business.tradingzon.com/images/itemimages/15Json Turneryg3 (135).jpg"
  },
  {
    "src": "https://business.tradingzon.com/images/itemimages/15Json Turnere (38).jpg"
  }
],"variants":[
  {
    "title": "Default Title",
    "barcode": "",
    "inventory_quantity": 8,
    "option1": "Default Title",
    "price": 5.49,
    "weight": 0.3,
    "weight_unit": "kg",
    "sku": "JSN-YG-02-1300",
    "grams": 0,
    "tracked": "true",
    "compare_at_price": 8,
    "inventory_policy": "deny"
  }
]}}

 

 

 

0 Likes
Jayvin
Shopify Partner
132 17 30

Hi,

Your json is malformed, copy and paste the json data here and you will see the error.

0 Likes