Skip to content

Instantly share code, notes, and snippets.

@chucknado
Last active August 29, 2015 14:23
Show Gist options
  • Save chucknado/55721abc0d8760253a5e to your computer and use it in GitHub Desktop.
Save chucknado/55721abc0d8760253a5e to your computer and use it in GitHub Desktop.
A Python script for the article "Changing the author of a Help Center article" at https://support.zendesk.com/hc/en-us/articles/205815128
import json
import requests
# Settings
article_id = your_article_id
updated_author_id = your_user_id
zendesk_subdomain = 'your_zendesk_subdomain'
email = 'your_user_email'
password = 'your_user_password'
# Structure and encode the data the way the API expects it
data = {'article': {'author_id': updated_author_id}}
payload = json.dumps(data)
# Make the request
url = 'https://{}.zendesk.com/api/v2/help_center/articles/{}.json'.format(zendesk_subdomain, article_id)
headers = {'Content-Type': 'application/json'}
auth = email, password
response = requests.put(url, data=payload, headers=headers, auth=auth)
if response.status_code != 200:
print('Failed to update article {} with error {}'.format(article_id, response.status_code))
exit()
print('Successfully updated the author of article {}'.format(article_id))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment