Zendesk Api Integration

9 Comments

  • Jack Gibson

    Hi Ameer,

     

    By the looks of it you are missing a subdomain, you cannot call https://zendesk.com directly, it needs to be a zendesk instance for example https://myzendesksubdomain.zendesk.com/api/v2/tickets would work fine providing your credentials are correct. 

    0
  • Ameer Hamza

    Thanks Jack for your valuable suggestion but now i have also added subdomain correctly as well as other credentials like username and token but it giving now this error.                                                  Client error: `GET https://cloudrepia.zendesk.com/api/v2/tickets.json` resulted in a `401 Unauthorized` response:\n{\"error\":\"Couldn't authenticate you\"}\n [details] {\"error\":\"Couldn't authenticate you\"}"

    0
  • Jack Gibson

    That is a step in the right direction, your credentials need to be in this format:

    email/token:token 

    so as an example:

    myemail@email.org/token:abc123apitoken

    It also needs to be a base64 encoded string.

     

    I hope this helps! 

    0
  • Ameer Hamza

    can you please share any example or a reference so it would very beneficial for me?

    0
  • Jack Gibson

    Ah apologies I misread that you are using the php library, I think to set up credentials properly you want to have something like this:

     

    use Zendesk\API\HttpClient as ZendeskAPI;
    
    $subdomain = "subdomain";
    $username  = "email@example.com"; // replace this with your registered email
    $token     = "6wiIBWbGkBMo1mRDMuVwkw1EPsNkeUj95PIz2akv"; // replace this with your token
    
    $client = new ZendeskAPI($subdomain);
    $client->setAuth('basic', ['username' => $username, 'token' => $token]);

    You can find the full documentation for the library you are using here

    0
  • Ameer Hamza

    yeah i am using php library and i am actually doing exact scenario as you mentioned above but still it is giving same authorization error.

    0
  • Jack Gibson

    I know it sounds silly but have you checked the API token and email combo you are using? Make sure to generate a new API token via the admin centre and copy / paste it to double check.

    0
  • Ameer Hamza

    yeah jack i also have checked this too by the way thank you so much for your guidance let me see further how it can be sort out.

    0
  • Atul Upadhyay

    The user id should be <email id>/token

    example - first.last@gmail.com/token

    0

Please sign in to leave a comment.

Powered by Zendesk