Closed domus71 closed 1 year ago
What happens when you try createV2?
I am getting the same issue:
const createdFulfillment = await shopify.fulfillment.create(
order.id,
{
location_id,
line_items
}
);
Error creating order: HTTPError: Response code 404 (Not Found)
at Request.<anonymous> (/<PATH>/shop-generate-orders/node_modules/.pnpm/got@11.8.6/node_modules/got/dist/source/as-promise/index.js:118:42)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'ERR_NON_2XX_3XX_RESPONSE',
timings: { ... }
}
}
Weeks ago this was working with no issues. I also tried using npm instead of pnpm and I get the same 404 error.
I tried createV2
and was able to get it to work.
As mentioned in issue #618 here
First get the fulfillment_order_id then use it into create request.
const fulfillmentOrderId = fulfillmentOrders[0].id;
const fulfillment = {
location_id: locationID,
line_items_by_fulfillment_order: [
{
fulfillment_order_id: fulfillmentOrderId,
fulfillment_order_line_items:
fulfillmentOrders[0].line_items || [],
},
],
};
const createdFulfillment = await shopify.fulfillment.createV2(
fulfillment,
);
@demo-mike Not sure what version you're on, but I'm using 2023-01
of Shopify's API and this is what I have in my TS for using the createV2
:
interface FulfillmentOrderTrackingInfo {
number?: string | number
url?: string | null
company?: string | null
}
interface FulfillmentOrderLineItem {
id: number
quantity: number
}
interface FulfillmentOrderLineItemsByFulfillmentOrder {
fulfillment_order_id: number
fulfillment_order_line_items: FulfillmentOrderLineItem[]
}
interface FulfillmentOrder {
message: string | null
notify_customer: boolean
tracking_info: FulfillmentOrderTrackingInfo
line_items_by_fulfillment_order: FulfillmentOrderLineItemsByFulfillmentOrder[]
}
// Code sample
const data:FulfillmentOrder = {}
await shopifyService.fulfillment.createV2(data)
I notice that if I give tracking info the fulfillment does not work!
I tried with:
tracking_number: "xxxxxxx",
tracking_company: "TNT"
I also tried:
tracking_info: [{
number: "xxxxxxxx",
company: "TNT",
}]
I also tried the updateTracking method with no success!
@domus71
What you had for tracking is the correct format:
tracking_info: [{
number: "xxxxxxxx",
company: "TNT",
}]
You're going to have to share the full object being passed to fulfillment.createV2
so I can assist further. The TS I've provided in my prior comment has been in production for awhile (version 2023-01
) so should be valid, granted everything else is correct.
The data for line_items_by_fulfillment_order: FulfillmentOrderLineItemsByFulfillmentOrder[]
is based off the data from shopify.order.fulfillmentOrders()
.
My code is:
const fulfillment_order = await shopify.order.fulfillmentOrders( 5083126759573 );
const _fulfillment_order_id = fulfillment_order[0].id;
await shopify.fulfillment.createV2({
location_id: 57932775573,
order_id: 5083126759573,
notify_customer: true,
tracking_info: [{ number: "999999999", company: "ACS Courier" }],
line_items_by_fulfillment_order: [
{
fulfillment_order_id: _fulfillment_order_id,
fulfillment_order_line_items: fulfillment_order[0].line_items || [],
},
],
});
thanks for your help
@domus71
I don't see location_id
and order_id
in the API docs.
Also, try mapping fulfillment_order_line_items: fulfillment_order[0].line_items
to only have id
, quantity
fields. I'm not sure if Shopify is throwing a hissy-fit for having additional fields.
Finally! Tracking info must be an object, not an array!
const response = await shopify.fulfillment.createV2({
notify_customer: true,
tracking_info: {
number: "999999999",
company: "ACS Courier",
},
line_items_by_fulfillment_order: [
{
fulfillment_order_id: _fulfillment_order_id,
},
],
});
@ikudosi thanks for your time!
Good thing you caught on. I'm ashamed even I mistook you had the right format for tracking_info lol.
Im still with the same error code: 'ERR_NON_2XX_3XX_RESPONSE',
```
const fullfilment = await currentShopify.connection.fulfillment.get(order_id) const fullfillmentId = fullfilment[0].id
const objetoMapeado = {
id: fullfilment[0].line_items[0].id,
quantity: fullfilment[0].line_items[0].quantity
};
var body = {
notify_customer: true,
tracking_info: { number: "999999999", company: "ACS Courier" },
line_items_by_fulfillment_order: [
{
fulfillment_order_id: fullfillmentId,
fulfillment_order_line_items: objetoMapeado || [],
},
],
};
await currentShopify.connection.fulfillment.insert(body).then(function (response) {
res.json({ success: response.status })
}).catch(function (error) {
logger.error(error.statusMessage)
})
i have tried with objetoMapeado and also with fullfilment[0].line_items. I had also test with location_id and order_id on the body but still the same error.
this is my insert function:
insert: function(body) { return shopify.fulfillment.createV2(body); },
I'm trying the following:
And returns 404 error (Not found)
Thnaks