Draft Order API Status code 301

alex_enchev
New Member
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
        }]
      }
    })
  })
}

 

0 Likes
alex_enchev
New Member
2 0 1

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