Error Product Insert - StatusCode: BadRequest- Required parameter missing

Hi,

I am trying to make a request to add a product using RestSharp and I am getting error Badrequest

“{"errors":{"product":"Required parameter missing or invalid"}}”

I have set Admin API permission [Read/Write] for Products on store settings

also Webhook Version matches with request

{X-Request-ID=6ea097eb-7668-467e-81cc-98a74a910151}

Here is my code ..Please provide some help. Am I missing something in JSON data?

var client = new RestClient(“https://bmswave.myshopify.com/”);
client.Authenticator = new HttpBasicAuthenticator(“xxx”, “xxx”);
https://bmswave.myshopify.com/admin/apps/private
string resource = “/admin/api/2021-10/products.json”;

var requestres = new RestRequest(resource, Method.POST);
StringBuilder postData = new StringBuilder();

postData.Append(“product:{”);
postData.Append(“title:Gloves Small Blk”);
postData.Append(“,”);
postData.Append(“body_html:Gloves Small Blk”);
postData.Append(“,”);
postData.Append(“vendor:BARTON INC”);
postData.Append(“,”);
postData.Append(“product_type:Dressing”);
postData.Append(“}”);

requestres.Method = Method.POST;
requestres.AddJsonBody(postData);
requestres.Parameters.Clear();
requestres.AddHeader(“content-type”, “application/json”);

var response = client.Execute(requestres);

So I figured it out with trial and error. Json format was wrong.

You need to add all values in double quotes

Of course you also have to make sure your private app has Read/Write rights for Product ..in Private App settings.

WITH IMAGE

body = @“{ ““product””:{ ““title””:”“” + title +
@“”" , ““images””:[{““src””:““https://[www.learningcontainer.com](http://www.learningcontainer.com)/wp-content/uploads/2020/07/Sample-JPEG-Image-File-Download-scaled.jpg””}]"
@" , ““body_html””:“”" + body_html +
@“”" }} ";

WITHOUT IMAGE

body = @“{ ““product””:{ ““title””:”“Test1234"” , ““body_html””:"“test ProductJan122022545"” }} ";