Creating carrier service never places inside of json file

Creating carrier service never places inside of json file

Indre2
Visitor
1 0 0

I am currently trying to add carrier service to the list of carriers, as I want to use third party carrier calculated shipping rates. I am using Shopify plan (billed annualy) and my develop app has `write_shipping` and `read_shipping` enabled.

The code which I execute is below:

const axios = require('axios');

const shopName = '[my_shop_name]';
const accessToken = '[my_access_token]';

const carrierServiceData = {
    "carrier_service": {
      "name": "[name]",
      "callback_url": "[callback_url]",
      "service_discovery": true
    }
  };
  
  async function createCarrierService() {
    try {
      const response = await axios.post(`https://${shopName}.myshopify.com/admin/api/2024-01/carrier_services.json`, carrierServiceData, {
        headers: {
          'X-Shopify-Access-Token': accessToken,
          'Content-Type': 'application/json',
        },
      });
  
      console.log('Carrier Service Created:', response.data);
    } catch (error) {
      console.error('Error creating carrier service:', error);
    }
  }
  
  createCarrierService();

Now, the response returns status 200, however, response.data returns and empty array, which means the carrier service never gets actually created and placed inside of carrier_services.json file. I have double checked all the parameters.

Reply 1 (1)

heypix
Visitor
1 0 0

I managed to work around the issue by substituting the domain with the default one assigned to the store. (df4b5a-a7.myshopify.com)

 

https://df4b5a-a7.myshopify.com/admin/api/2024-01/carrier_services.json