I need to create the custom product by the Shopify Storefront.
Documentation link: http://docs.shopify.com/api/product#create
I have tried the following code:
$('#addProduct').click(function() {
$.ajax({
url:'https://xxxxxx:[email protected]/admin/products.json',
type: 'POST',
contentType : 'application/json',
dataType: 'json',
data: {
"product": {
"title": "Burton Custom Freestlye 151",
"body_html": "<strong>Good snowboard!</strong>",
"vendor": "Burton",
"product_type": "Snowboard",
"tags": "Barnes & Noble, John's Fav, \"Big Air\""
}
},
success: function(response) {
console.log(response);
},
error: function(xhr) {
console.log(xhr.statusText);
}
}).done(function(data) {
console.log(data);
});
});
The above code shows the following error in Chrome console while ajax request:
OPTIONS https://rmisys.myshopify.com/admin/products.json 405 (Not Allowed) jquery-1.10.2.js:8706 OPTIONS https://rmisys.myshopify.com/admin/products.json No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://rmisys.myshopify.com' is therefore not allowed access. jquery-1.10.2.js:8706 XMLHttpRequest cannot load https://rmisys.myshopify.com/admin/products.json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://rmisys.myshopify.com' is therefore not allowed access. design-your-shirt:1 error