404 error during attempted export of KB articles

5 댓글

  • Nathan van Jole

    The locale needs to be in lowercase. In this line:

    endpoint = zendesk + '/api/v2/help_center/en-US/articles.json'.format(locale=language.lower())

    You hardcoded the "en-US" which should be replaced with "{locale}". Also make sure to set the language variable to "en-US" instead "en_US" (with underscore).

    Hope this helps!

    0
  • Charles Nadeau
    Zendesk Documentation Team

    Also, an API token in Zendesk is different than an OAuth token. So the following header won't work:

    headers = {
        'Authorization': f'Bearer {api_token}',
    }

    An API token should be used as follows in a Python request (see API token in the docs for details):

    api_token = 'MY_ZENDESK_TOKEN'
    your_email_address = 'myself@example.com'
    credentials = f'{your_email_address}/token', f'{api_token}'

    In the API request, add the `credentials` variable to the `auth` parameter:

    response = requests.get(endpoint, auth=credentials)

     

     

    0
  • Mark Glinski

    Thank you for the suggestions Nathan van Jole and Charles Nadeau!

    So, now I'm no longer getting a 404. Now I'm getting different output after running the script:

    First, there's a list of 30 article IDs from our KB.

    Then there's a message: 

    Failed to retrieve articles with error 200: (which is weird because 200 is typically a "success" message)

    ...which is followed by a massive blob of text. I analyzed the text and it includes all the IDs in that list of 30.

    Then, for each article ID, it shows some words from the article and some metadata. 

    And the backup folder that gets created by the script is empty.

    Has anyone experienced this?


    0
  • Mark Glinski

    Also, Charles Nadeau, regarding your comment about using an OAuth header ^^ should I replace that header or just get rid of it?

    Your comment for reference: 

    Also, an API token in Zendesk is different than an OAuth token. So the following header won't work:

    headers = {
        'Authorization': f'Bearer {api_token}',
    }
    0
  • Charles Nadeau
    Zendesk Documentation Team

    Yes, you should delete the header.

    0

댓글을 남기려면 로그인하세요.

Zendesk 제공