A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
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 👋
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": "<p>foobar</p>",
"published_at": "Jan 1 15:45:47 UTC 2023"
}
}
requests.put(endpoint, json=payload, headers=headers)
Hope that helps!
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
You helped me a lot!! Have been trying to fix this issue for almost an hour now, Thank you 🙂