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.