How can I create order hrough jquery with Object API Shopify?

Solved
sstefanm
Shopify Partner
11 3 7

Greetings, I tried to create reorder button for the user when the user click that button I send ajax request to server but I'm getting server code 301 and server said like it's problem with JSON but when I checked my JSON on validator is everything fine, can someone help me with this problem here is the code

var order = {
                          "order":{
                            "line_items": [
                              {
                                "variant_id": variant_id,
                                "quantity": quantity
                              }
                            ]
                          }
                        }

                        var orderJSON = JSON.stringify(order);

                        $.cookie("session", null);

                        $.ajax({
                            url:'https://API:PASSWORD@creamyrad.myshopify.com/admin/api/2021-07/orders.json',
                            type: 'POST',
                            data: order,
                            dataType: "json",
                            crossDomain: true,
                            cache: false,
                            success: function(response) {
                                console.log(response);
                            },
                            error: function(response, status, xhr) {
                                console.log("-------------------------------- <ERROR> --------------------------------");
                                console.log(response);
                                console.log(status);
                                console.log(xhr);
                                console.log("-------------------------------- </ERROR> --------------------------------");
                            }
                        });
Stefan Momcilovic
Accepted Solution (1)

Accepted Solutions
Cellify
Shopify Partner
54 3 15

This is an accepted solution.

You can not create order via jquery. You need custom or private app with permissions to do so

View solution in original post

Reply 1 (1)
Cellify
Shopify Partner
54 3 15

This is an accepted solution.

You can not create order via jquery. You need custom or private app with permissions to do so