Update shopify articles using api

Topic summary

A developer encountered a “Required parameter missing: ‘article’” error when attempting to update a Shopify article’s author and publication date via the REST API in Python.

Issue identified:

  • The data2 dictionary wasn’t being passed correctly to the requests.put() method
  • Without specifying the json keyword argument, the payload was treated as the positional data parameter, requiring manual encoding

Solution provided:
A Shopify support representative shared working Python code demonstrating:

  • Proper use of json=payload keyword argument in requests.put()
  • Correct payload structure with nested article object containing id, title, body_html, and published_at fields
  • Required headers including X-Shopify-Access-Token

Outcome:
The original poster confirmed the solution resolved their issue after nearly an hour of troubleshooting.

Summarized with AI on November 7. AI used: claude-sonnet-4-5-20250929.

Hello,

I want to update an article author and date.

I am using below code in python .

URL3 = “https://abc:xyz@def.myshopify.com/admin/api/2023-01/blogs/1111/articles/22222.json

article={‘id’:3333,‘blog_id’:44444,‘published_at’:‘2017-04-26T12:27:42+05:30’,‘title’:‘Is There Any Natural ?’}

data2={‘article’:article}

r = requests.put(data2)//Not exactly like this but data2

I am getting the error.

{‘errors’: {‘article’: ‘Required parameter missing or invalid’}}

Hi @shm :waving_hand:

You’ll need to ensure that data2 dict is passed as the json keyword argument. If the keyword isn’t specified, it will read it as the data (positional) parameter, which expects a encoded dictionary (i.e. data=json.dumps(payload)) and the article payload values may not be read fully. Below is one sample implementation using requests:

headers = {"X-Shopify-Access-Token": ADMIN_ACCESS_TOKEN}
rest_url = lambda r: f"https://{SHOP_NAME}.myshopify.com/admin/api/{VERSION}/{r}.json"
blog, article = 77350109302, 588192252022
endpoint = rest_url(f"blogs/{blog}/articles/{article}")
payload = {
    "article": {
        "id": article,
        "title": "new title",
        "body_html": "

foobar

",
        "published_at": "Jan 1 15:45:47 UTC 2023"
    }
}
requests.put(endpoint, json=payload, headers=headers)

Hope that helps!

1 Like

You helped me a lot!! Have been trying to fix this issue for almost an hour now, Thank you :slightly_smiling_face: