Recent searches
No recent searches
Ability to get 'review_status' in GET article API
Posted Sep 09, 2022
Hi,
I am writing a script to update the URLs in the article body to include the lang_loc.
When I run the script it updates all the articles correctly. However if there is an article with 'review_status = in progress' it will update the published article and republish, putting the in progress work into revisions in it's past.
Either I would like to be able to get the 'revision status' in the API somehow, so I can ignore them, or be able to update the published article keeping the in progress article there.
Any ideas?
Thanks,
Amy
Code:
endpoint = zendesk + '/api/v2/help_center/{locale}/articles.json'.format(locale=locale.lower())
## get the locale from locale var and insert it into {locale}
while endpoint:
# While the end point exists continue
response = requests.get(endpoint, auth=credentials)
## Get the data from each locale get
if response.status_code != 200:
print('Failed to retrieve articles with error {}'.format(response.status_code))
exit()
data = response.json()
#print(f'The end point: ' + endpoint)
for article in data['articles']:
print(article)
article_id = article['id']
if "/hc/articles/" in str(article['body']):
print(article['html_url'])
## If the article body contains a link without a locale
output_article = article['body'].replace('/hc/articles/', '/hc/'+locale+'/articles/')
## Replace the urls to include the current locale
put_url = f'https://mysite.zendesk.com/api/v2/help_center/articles/{article_id}/translations/{locale}.json'
put_data = {'translation': {'title': article['title'], 'body': output_article}}
put_response = requests.put(put_url, json=put_data, auth=credentials)
# Put the response back to the article replaced with the new urls
print(str(article['html_url']))
endpoint = data['next_page']
# Go to the next page of articles
1
0
0 comments