How to create a customer via post REST API

New Member
4 0 0

In postman, I want to create a customer by post to this url:

https://user:pass@mysite.myshopify.com/admin/customers.json

 

{
  "customer": {
    "first_name": "Steve",
    "last_name": "Lastnameson",
    "email": "steve.lastnameson@example.com",
    "phone": "+15142546011",
    "verified_email": true,
    "addresses": [
      {
        "address1": "123 Oak St",
        "city": "Ottawa",
        "province": "ON",
        "phone": "555-1212",
        "zip": "123 ABC",
        "last_name": "Lastnameson",
        "first_name": "Mother",
        "country": "CA"
      }
    ],
    "password": "newpass",
    "password_confirmation": "newpass",
    "send_email_welcome": false
  }
}

 

Instead, I got something like this. I expect it just creates a customer directly

 

 

<html>
    <body>
        <noscript>
            <a href="https://accounts.shopify.com/oauth/authorize?client_id=7ee65a63608843c577db8b23c4d7316ea0a01bd2f7594f8a9c06ea668c1b775c&amp;destination_uuid=b4eda884-65f5-4297-b09f-341ec310ab64&amp;nonce=27ced0ba04537fa341d5f2e7b5bd3f72&amp;redirect_uri=https%3A%2F%2Fapp.shopify.com%2Fidentity%2Fauthorize%2Fcallback&amp;response_type=code&amp;scope=openid+email+profile&amp;state=fdc99206a6c218ad88be11250366a45b&amp;ui_locales=en&amp;ux=shop">Continue</a>
        </noscript>
        <script type="text/javascript">
      window.location = "https:\/\/accounts.shopify.com\/oauth\/authorize?client_id=7ee65a63608843c577db8b23c4d7316ea0a01bd2f7594f8a9c06ea668c1b775c\u0026destination_uuid=b4eda884-65f5-4297-b09f-341ec310ab64\u0026nonce=27ced0ba04537fa341d5f2e7b5bd3f72\u0026redirect_uri=https%3A%2F%2Fapp.shopify.com%2Fidentity%2Fauthorize%2Fcallback\u0026response_type=code\u0026scope=openid+email+profile\u0026state=fdc99206a6c218ad88be11250366a45b\u0026ui_locales=en\u0026ux=shop";
    </script>
    </body>
</html>

 

0 Likes
Highlighted
Shopify Partner
1841 170 483

The admin API will always redirect to login page if cookies are sent along in a POST request. That's documented somewhere.

 

You need to clear your cookies from the Postman session which are held in Chrome. I don't use Postman so I can't give you specific instructions how to approach this but you can read up here or Google how to do it.

 

Better solution, switch to Insomnia (and read this little gem written by Shopify) and live happily ever after.

 

Best wishes!

I turn coffee in to code - since 1998
0 Likes