I am trying to update customer tag on Shopify by using its private app. I tried it with postman and everything is working fine but via AJAX, it takes me to success callback instead of error but in success I get auth link instead of customer record like I get in postman.
$.ajax({
type: "POST",
url: "https://secret:password@store-name.myshopify.com/admin/customers/1569902297146.json",
contentType: 'application/json',
data: JSON.stringify({
customer: {
id: "1569902297146",
email: "example@gmail.com",
tags: "loyalty-member"
}
}),
success: function(msg, b ,b) {
console.log(msg);
},
error: function(a, b, c) {
console.log(msg);
}
});
I did not find any productive answer/info over the internet. Finally, After hit and trial with AJAX I am able to get success result.
$.ajax({
type: "POST",
url: "https://secret:password@store-name.myshopify.com/admin/customers/1569902297146.json",
contentType: 'application/json',
crossDomain: true,
data: JSON.stringify({
customer: {
id: "1569902297146",
email: "example@gmail.com",
tags: "loyalty-member"
}
}),
success: function(msg, b ,b) {
console.log(msg);
},
error: function(a, b, c) {
console.log(msg);
}
});
The real hero is crossDomain. I don't know why Shoify do not allow its PUT and POST requests without making crossDomain: true,