Creating fulfillment for specific order items wont work: Bad Request 400

LORhys
Shopify Partner
4 0 0

Hey Guys,

I am really new to the Shopify API and I am now facing the task of connecting an API with an external vendor. I have managed to set up the API with running some JS on via the App "Cloud Hooks" however I am facing some issues when trying to post the fulfillment details to shopify.

Currently I'm just testing the post and can't seem to get it working. All I get is a generic 400 Bad Request without further information.

I'm sure doing such a thing should be pretty common for some veteran shopify devs. Could someone give me a hand? I tried casting the non string values to strings and still had the same response.

Thanks and kind regards,

PS: The authentication worked fine so that shouldn't be the issue.

Rhys

Screenshot 2021-10-12 at 23.23.04.png

Replies 5 (5)

LORhys
Shopify Partner
4 0 0

Btw, I tried it like this initialy.

Also both the order number and the line_item_id where taken from actual orders off of my store.

Screenshot 2021-10-12 at 23.33.10.png

cyclic_science
Tourist
6 0 1

I've used this endpoint extensively, although not recently.

Assuming your IDs for the order and order_items are correct, I'd check if fulfillments already exist on the order. Store settings can have a fulfillment created early in the lifecycle automatically, which you would need to "complete" rather than create a new fulfillment. Alternatively, you could cancel the existing fulfillment to allow you to create a new one.

LORhys
Shopify Partner
4 0 0

Thanks for your swift response!

So I've checked the order json and the fulfillments array is still initial and the I checked the order id by pasting it out of my code to the header and the line_item.id seems to be correct aswell:

"fulfillments":[],"line_items":[{"id":10681151389885

 Am I correct in thinking this endpoint should be used for partially fulfilling / for completely fulfilling depending on if all items are addressed or not? Or am I using the wrong endpoint. As I have quite a few different suppliers I want to use this endpoint to add the tracking info to only the line items that are from one vendor and add the shipping info that a receive as a response. Would this cause the order to be set to partially fulfilled / fulfilled respectively or have I misunderstood the endpoint?

Thanks in advance!

cyclic_science
Tourist
6 0 1

Your concept of partially fulfilling orders is correct.

Take a look at the `location` concept, as described in the note at the top of this doc:

https://shopify.dev/api/admin-rest/2021-10/resources/fulfillment#top

I don't see a location_id in your request, which matches some of the example code. Elsewhere, the docs show it as required:

https://shopify.dev/api/admin-rest/2021-10/resources/fulfillment#[post]/admin/api/2021-10/orders/{or...

VitaF
Shopify Partner
159 2 28

Hello!

You might want to check out an app called Trackr

It is an order tracking app that provides real-time information from more than 900 carriers globally. The app allows you to add an order tracking page to your store so that the customers can follow their parcel journey themselves by simply filling in their order information. And if you ever run into any trouble, their support time is very fast and effective. 🙂

Helpcenterapp