Failed to update draft order. Status code: 400

Topic summary

Issue: Updating a Shopify draft order via REST returns 400 with {“errors”:{“draft_order”:“Required parameter missing or invalid”}} on a live store, while the same code works on a partner test store.

Context and intent: The goal is to fix incomplete addresses on draft orders. For testing, the author re-sent the unmodified draft order JSON back to the update endpoint, but the error persists.

Implementation details: Python requests to GET /admin/api/2024-07/draft_orders.json and PUT /admin/api/2024-07/draft_orders/{id}.json with headers (X-Shopify-Access-Token, application/json). Body sent as {“draft_order”: }. Author states all access scopes are enabled. Code snippets are central to the discussion.

Requests from responder: Asked for the exact request parameters/payload and provided an example of a minimal valid body (“draft_order” with id and line_items) to compare against.

Current state: No resolution. The discrepancy appears store-specific, and a parameter issue is suspected, but the exact failing payload hasn’t been shared yet. Next step is to provide the precise request body and parameters from the live store for further diagnosis.

Summarized with AI on December 23. AI used: gpt-5.

I get some draft orders with incomplete addresses and I am trying o update them but everything I tried failed to work. Now I am passing the exact same draft order json and yet it continues to give me the same error,

Response: {"errors":{"draft_order":"Required parameter missing or invalid"}}

All access scopes have been allowed. I use this same code for my partner test store, and it works, but I need some help here.


Hi @safwanadnan

There is an issue with the parameters. Please send your request parameters for processing.

This is my code, works fine for my test store but the actual store it returns an error

import requests
import json

Define the API endpoints and access credentials

store_url = “”
access_token = “”
draft_orders_endpoint = “/admin/api/2024-07/draft_orders.json?limit=1”
update_endpoint_template = “/admin/api/2024-07/draft_orders/{draft_order_id}.json”

Set up the headers with the access token

headers = {
“X-Shopify-Access-Token”: access_token,
“Content-Type”: “application/json”
}

Function to fetch draft orders

def fetch_draft_orders():
url = f"{store_url}{draft_orders_endpoint}"
response = requests.get(url, headers=headers)
if response.status_code == 200:
return response.json()
else:
print(f"Failed to fetch draft orders. Status code: {response.status_code}")
print(“Response:”, response.text)
return None

Function to update draft order note attributes

def update_draft_order(draft_order):
draft_order_id = draft_order.get(‘id’)
update_url = f"{store_url}{update_endpoint_template.format(draft_order_id=draft_order_id)}"
data = {
“draft_order”: draft_order
}
response = requests.put(update_url, headers=headers, json=data)
if response.status_code == 200:
print(f"Draft order {draft_order_id} updated successfully.“)
return response.json()
else:
print(f"Failed to update draft order {draft_order_id}. Status code: {response.status_code}”)
print(“Response:”, response.text)
return None

Fetch the draft orders

draft_orders_data = fetch_draft_orders()

if draft_orders_data:
draft_orders = draft_orders_data.get(‘draft_orders’, )
if draft_orders:
first_draft_order = draft_orders[0]

Update the draft order with the same note attributes

updated_draft_order = update_draft_order(first_draft_order)
if updated_draft_order:
print(“Updated Draft Order:”, updated_draft_order)
else:
print(“No draft orders found.”)
else:
print(“Failed to retrieve draft orders.”)

Hi @safwanadnan

I need to request parameters, such as the following code:

{
"draft_order":{
"id":"123198237",
"line_items":[{"variant_id":447654529,"quantity":1}]
}
}

That’s what I’m saying, I fetched the entire order and first replaced the address in the order with itself just for testing purposes so that nothing is actually changed, it threw the same error, so I passed the entire order json as parameter to see if something is missing maybe that works but no same error persists. Funny thing is that both versions of codes worked perfectly fine with ny test store but the actual store e throws an error.

As you can see in the code I fetched a draft order, parsed it’s contents and then passed that exact same json which contained the contents but it says error.