Covers all questions related to inventory management, order fulfillment, and shipping.
Error: Response code 400 (Bad Request)
at Request.<anonymous> (c:\nodejs\node_modules\got\dist\source\as-promise\index.js:118:42)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {name: 'HTTPError', code: 'ERR_NON_2XX_3XX_RESPONSE', timings: {…}, stack: 'HTTPError: Response code 400 (Bad Request)
…ions (node:internal/process/task_queues:95:5)', message: 'Response code 400 (Bad Request)', …}
Adjust your logic SLIGHTLY and let me know:
const fulfillment = {
order_id: orderId,
line_items: [{
id: secondLineItem.id,
quantity: 1 // Assuming you want to fulfill 1 quantity of the second line item
}]
};
Make sure to replace quantity: 1 with the appropriate quantity if you need to fulfill more than one unit of the product. Also, double-check that your orderId variable is correctly set and passed to the fulfillSecondLineItem function.
Thanks for your suggestion. I tried it and still got a 400. I have verified that the order id is correct. I have to assume the line item id is correct since it was pulled from the line items downloaded with the order. Is the Shopify API supposed to supply any kind of error code or message that could serve as a clue? I burrowed through the error response but could not find anything meaningful (to me, at least).
const fulfillment = {
"order_id": "5847711088977",
"line_items": [
{
"id": 15197089562997,
"quantity": 1
}
]
}
Error: HTTPError: Response code 400 (Bad Request)
at Request.<anonymous> (c:\nodejs\node_modules\got\dist\source\as-promise\index.js:118:42)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
{name: 'HTTPError', code: 'ERR_NON_2XX_3XX_RESPONSE', timings: {…}, stack: 'HTTPError: Response code 400 (Bad Request)
…ions (node:internal/process/task_queues:95:5)', message: 'Response code 400 (Bad Request)', …}
To better understand the cause of the error, you can modify your error handling to log the complete error response from Shopify. This should include more detailed information about what's specifically wrong with your request. Here's how you can modify your catch block to log the complete error response:
catch (error) {
if (error.response) {
console.error('Error Response:', error.response.body); // Log the full error response
} else {
console.error('Error:', error);
}
}
That was very helpful! The error message I got back was "location_id must be specified when creating fulfillments."
We only have one location, and in the downloaded order json, location_id was null. I am wondering where I am supposed to specify the fulfillment_id and if I should just specify null, or is there some config flag somewhere which indicates that location_id is not necessary?
Thx!
Awesome! I am super glad to hear it!
You can use the GET /admin/api/2023-10/locations.json or /admin/api/2024-01/locations.json (for the latest endpoint) to list all locations for your shop.
The response will include the ID for each location. If you only have one location, this will be the location_id you need.
I used the GraphQL tool to get the shop location_id and put it in fulfillment, however I still got the same error ("location_id must be specified when creating fulfillments".
fullfilment: { "order_id": "5847711088933", "line_items": [ { "id": 15197089562917, "quantity": 1, "location_id": "73224487205" } ] }
Moving location_id from line item level to order level got rid of the "location_id must specified ..." error, but now results in a 404. However, I think I have some more homework to on learning how to do create fulfillments.
fulfillment: { "order_id": "5856379699493", "location_id": "73224487205", "line_items": [ { "id": 15210794484005, "quantity": 1 }] }