Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Draft Order API Status code 301

Draft Order API Status code 301

alex_enchev
Visitor
2 0 1

Hi there, I try to create Draft Order from frontend via Admin API. When I use Postman everything is OK, but when I try to create order from frontend always returns 301 fetch/Redirect.

Can anybody help me with this pain 😄

This is my function:

function apiCall() {
  return fetch('https://myapp.myshopify.com/admin/api/2021-04/draft_orders.json', {
    'method': 'POST',
    'headers': {
      'X-Shopify-Access-Token': "TOKEN",
      'Content-Type': 'application/json'
    },
    'body': JSON.stringify({
      "draft_order": {
        "line_items": [{
            "variant_id": 99999999999,
            "quantity": 1
        }]
      }
    })
  })
}

 

Reply 1 (1)

alex_enchev
Visitor
2 0 1

I found solution, the answer is to pass password for Access Token, not the API key