Magento-RestApi
Magento-RestApi copied to clipboard
CreateNewProduct
Hello, I'm not sure if this is a bug, or i'm doing something completely wrong.
I am using a button to:
private async void button1_Click(object sender, EventArgs e) { client.Initialize("http://www.MySite.com", "Consumer", "Secret"); client.AuthenticateAdmin("User", "Pass"); await AddProducts(); }
Which runs:
`private async Task AddProducts() {
Debug.WriteLine("Working");
string mySku = "FPP 923829832";
Product prod = new Product
{
name = "Name",
description = "Raider",
short_description = "supershort",
sku = mySku,
price = 12.34,
type_id = "simple",
attribute_set_id = 4,
weight = 1,
status = ProductStatus.Enabled,
visibility = ProductVisibility.CatalogSearch,
tax_class_id = 0
};
var response = client.CreateNewProduct(prod).Result;
if (response.HasErrors)
{
label2.Text = "Error : " + response.ErrorString;
}
else
{
var newProduct = client.GetProductBySku(mySku).Result;
label2.Text = "Success : " + newProduct.Result.entity_id.ToString();
}
Debug.WriteLine("DONE Working");
}`
It seems to be hanging up on:
var response = client.CreateNewProduct(prod).Result;
According to fiddler, the response is:
{"messages":{"error":[{"code":400,"message":"The request data is invalid."}]}}
I am using Magento Community 1.9.2.4 if that helps anything.
Thanks.
Are you running this in an asp.net website?