Liquid, JavaScript, themes, sales channels
Hello!
I'm trying to create a price rule using the Admin API from the documentation, but I have a problem: I get a strange 303 status on post request. If I add contentType: "application / json" I get 400 bad request. Please tell me what could be the problem? Thank you.
Code (with test static post data):
$.ajax({
url: '/admin/api/2021-01/price_rules.json',
contentType: "application/json",
type: 'POST',
data: {
"price_rule": {
"title": "TESTDISCOUNT",
"target_type": "line_item",
"target_selection": "all",
"allocation_method": "across",
"value_type": "fixed_amount",
"value": "-10.0",
"customer_selection": "all",
"starts_at": "2020-01-19T17:59:10Z"
}
},
success: function (response) {
setTimeout(function () {
console.log(response);
},
error: function(xhr) {
console.log('xhr', xhr);
}
})
You can't use the Admin API on the front-end with an Ajax request. You need an app that can properly authenticate on the back-end.
Thank you for answer. Are you sure? GET request works very well.
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024