REST API curl fulfillment - Bad Request

Solved

REST API curl fulfillment - Bad Request

rmanev
Shopify Partner
3 0 2
curl -d '{"fulfillment":{"line_items_by_fulfillment_order":[{"fulfillment_order_id":5702762856492}],"tracking_info":{"number":"MS1562678","url":"https://www.usps.com?tracking_number=MS1562678"}}}' -X POST "https://image-devstore.myshopify.com/admin/api/2023-04/fulfillments.json" -H "X-Shopify-Access-Token: XXXXXXXXXXXXXXXX" -H "Content-Type: application/json"

 

Can someone tell me why do I get back Bad Request response from the above request?
The app has sufficient permissions to use fulfillments resaources.
The same request made with PHP successfully create the fulfillment.

 

Accepted Solution (1)
chetancrao
Shopify Partner
42 5 5

This is an accepted solution.

Hi @rmanev 

 

I have checked the Postman collection you have shared, and there seems to be the API endpoint was incorrect. Also, I have corrected that, and I have tested the same with one of my test stores. Please give it a try one more time.

First, make an API call named "Fetch order fulfillments" and pass the order id to it, then once you receive a response from the fetch API, use the id from 

fulfillment_orders array in the next API call named "Create order fulfillment".
 
 
Thanks.
Cheetos || Recurpay Subscriptions

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution

View solution in original post

Replies 3 (3)

chetancrao
Shopify Partner
42 5 5

Hello @rmanev,

 

Thank you for reaching out to the Shopify community.

 

I kindly request you to review the request payload and headers that you are currently passing. In order to provide you with a helpful reference, I have attached a sample working cURL command below:

curl --location 'https://cheetosr.myshopify.com/admin/api/2023-04/fulfillments.json' \
--header 'X-Shopify-Access-Token: your_access_token' \
--header 'Content-Type: application/json' \
--data '{
    "fulfillment": {
        "line_items_by_fulfillment_order": [{
            "fulfillment_order_id": 6307931226386
        }],
        "tracking_info": {
            "number": "MS12345",
            "url": "https://www.usps.com?tracking_number=MS12345"
        }
    }
}'

 

Furthermore, if the issue persists, I would appreciate it if you could respond with the response details, including the HTTP status code, and if possible, a Postman export. This additional information would enable me to conduct a thorough examination of the request and promptly resolve the issue on your behalf.

 

Thanks.

Cheetos || Recurpay Subscriptions

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
rmanev
Shopify Partner
3 0 2

Hi @chetancrao 

Thank you for your response.

 

OS: Windows 10

CLI: Command Prompt

We have tried your suggested cURL through command line. Copy/paste your exact line with the proper URL/Token produced an error:

 

curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (6) Could not resolve host: application
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) unmatched brace in URL position 1:
{

 

 

I had to slightly  modify the line removing space intervals to avoid the above error. Here is the line I came up with:

 

curl --location "https://image-devstore.myshopify.com/admin/api/2023-04/fulfillments.json" --header "X-Shopify-Access-Token: {our_token}" --header 'Content-Type:application/json' --data '{"fulfillment":{"line_items_by_fulfillment_order":[{"fulfillment_order_id":5702836650028}],"tracking_info":{"number":"MS12345","url":"https://www.usps.com?tracking_number=MS12345"}}}'

 

 

Here is the respond:

 

{"errors":{"fulfillment":"Required parameter missing or invalid"}}

 

 

I'm also attaching the Postman json file for reference. 

chetancrao
Shopify Partner
42 5 5

This is an accepted solution.

Hi @rmanev 

 

I have checked the Postman collection you have shared, and there seems to be the API endpoint was incorrect. Also, I have corrected that, and I have tested the same with one of my test stores. Please give it a try one more time.

First, make an API call named "Fetch order fulfillments" and pass the order id to it, then once you receive a response from the fetch API, use the id from 

fulfillment_orders array in the next API call named "Create order fulfillment".
 
 
Thanks.
Cheetos || Recurpay Subscriptions

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution