Solved

Tracking number update results in Internal Server Error

kimchirichie
Tourist
3 1 0

I am following the fulfillment REST API documentation on making a call to update the tracking number on a fulfillment.

Following is my Python script fired on Zapier:

 

endpoint = "https://thecostumeshop.myshopify.com/admin/api/2022-04/fulfillments/{fulfillment_id}/update_tracking.json".format(
    fulfillment_id=input_data['fulfillment_id']
)

# send fulfillment tracking number
output = requests.post(
    endpoint,
    headers={'X-Shopify-Access-Token': '[__REDACTED_API_TOKEN__]'},
    data={
        'fulfillment': {
            'notify_customer': True,
            'tracking_info': {
                'company': input_data['company'],
                'number': input_data['tracking_number'],
                'url': input_data['tracking_url'],
            },
        }
    },
).json()

 

 

All I get back from this request is a vague error message:

 

{errors: "Internal Server Error"}

 

 

Which makes me think this is an unexpected 500 error. What am I doing wrong here? Is there anyway to debug these vague "Internal Error" responses?

Accepted Solution (1)

kimchirichie
Tourist
3 1 0

This is an accepted solution.

I was able to resolve this by adding a header, and the right write permissions:

 

permission policies to be enabled:

write_merchant_managed_fulfillment_orders

write_third_party_fulfillment_orders

 

My Python code snippet:

endpoint = "https://thecostumeshop.myshopify.com/admin/api/2022-04/fulfillments/{fulfillment_id}/update_tracking.json".format(
    fulfillment_id=input_data['fulfillment_id'],
)

# send fulfillment tracking number
output = requests.post(
    endpoint,
    headers={
        'Content-Type': 'application/json',
        'X-Shopify-Access-Token': '[__REDACTED_API_KEY__]',
    },
    json={
        'fulfillment': {
            'notify_customer': True,
            'tracking_info': {
                'company': input_data['company'],
                'number': input_data['tracking_number'],
                'url': input_data['tracking_url'],
            },
        }
    },
)

 

View solution in original post

Replies 2 (2)

kimchirichie
Tourist
3 1 0

This is an accepted solution.

I was able to resolve this by adding a header, and the right write permissions:

 

permission policies to be enabled:

write_merchant_managed_fulfillment_orders

write_third_party_fulfillment_orders

 

My Python code snippet:

endpoint = "https://thecostumeshop.myshopify.com/admin/api/2022-04/fulfillments/{fulfillment_id}/update_tracking.json".format(
    fulfillment_id=input_data['fulfillment_id'],
)

# send fulfillment tracking number
output = requests.post(
    endpoint,
    headers={
        'Content-Type': 'application/json',
        'X-Shopify-Access-Token': '[__REDACTED_API_KEY__]',
    },
    json={
        'fulfillment': {
            'notify_customer': True,
            'tracking_info': {
                'company': input_data['company'],
                'number': input_data['tracking_number'],
                'url': input_data['tracking_url'],
            },
        }
    },
)

 

SuneelG
Shopify Partner
11 0 0

Glad to were able to solve the problem But how did you arrive at the diagnosis that it was a permission error. I'm having a similar error (internal Error) while duplicating some store information from one to the other store ( which is not available via direct export / import ) but on retry it works at times, and in other cases generates an API limit error even though the API usage is showing 1/40. 

Can you please share how you diagnosed the underlying problem