POST method works in Postman, but returns the login page when using axios

New Member
2 0 0

When I make a post request to the following URL in Postman, and pass the raw data below, I get a 201 status code and the price rule is created successfully. But, when I try the same thing with axios, the api returns a 200 status code and the response data is the html of the login page.


  "price_rule": {
    "title": "TESTPRICERULE2",
    "target_type": "line_item",
    "target_selection": "entitled",
    "allocation_method": "across",
    "value_type": "percentage",
    "value": "-100.0",
    "customer_selection": "all",
    "usage_limit": "1",
    "entitled_product_ids": ["5591610753175"],
    "starts_at": "2020-09-02T17:59:10Z"

Here's how I'm making the post request with axios:

    const data = {
      price_rule: {
        title: "TESTPRICERULE2",
        value_type: "percentage",
        value: "-100.0",
        entitled_product_ids: ["5591610753175"],
        allocation_method: "across",
        once_per_customer: "false",
        usage_limit: "1",
        customer_selection: "all",
        target_type: "line_item",
        target_selection: "entitled",      
        starts_at: new Date()  

   const url = "https://<apikey>:<password>";, data).then(res => {
        console.log(; // is html


Shopify Expert
10037 119 1873

Is this fair to assume you’re making an API call via the browser or is this server side code?

You’ll be exposing the key details to the public if client side so that’s pretty scary to begin with. As for the block, If sending via the browser it’s going to include cookies so will be blocked for good security reasons. 

If it is server side and you’re sure the details are protection, there’s an alternative approach but let’s cover off the assumptions above first.


★ Winning Partner of the Build a Business competition. ★
New Member
2 0 0

Thank you! I already figured it out. I had to pass the password as a content header.