Hi everyone,
I have just started with Shopify. I am trying to create a fulfilment using this code
import Shopify from ‘shopify-api-node’;
const shopifyCon = new Shopify({
shopName: ‘demo-shopname’,
accessToken: ‘ACCESSTOKEN’,
apiVersion: ‘2023-04’
});
const createFulfillment = async (orderId, fulfillmentData) => {
try {
const fulfillment = await shopifyCon.fulfillment.create(orderId, fulfillmentData);
console.log(‘Fulfillment created:’, fulfillment);
} catch (error) {
console.error(‘Error creating fulfillment:’, error);
}
};
// Usage example:
const orderId = ‘123456789’; // Replace with your order ID
const fulfillmentData = {
tracking_number: ‘1234567890’, // Replace with the tracking number
tracking_urls: [‘https://example.com/tracking’], // Replace with the tracking URL(s)
line_items: [
{
id: ‘987654321’, // Replace with the line item ID
quantity: 1 // Replace with the quantity to fulfill
}
]
};
createFulfillment(orderId, fulfillmentData);
I am getting this error
Error creating fulfillment: HTTPError: Response code 400 (Bad Request)
code: ‘ERR_NON_2XX_3XX_RESPONSE’,
timings: {
start: 1685883653312,
socket: 1685883653314,
lookup: 1685883653369,
connect: 1685883653449,
secureConnect: 1685883653527,
upload: 1685883653529,
response: 1685883654072,
end: 1685883654075,
error: undefined,
abort: undefined,
phases: {
wait: 2,
dns: 55,
tcp: 80,
tls: 78,
request: 2,
firstByte: 543,
download: 3,
total: 763
}
}
}
I can fetch the order details using this code :
const shopOrder = await shopifyCon.order.get(orderId);
But fulfilment creation is giving me an error. Please guide.