'What is the correct way of create a get request for retrieve a tickets in zendesk

if my username is [email protected] and API token is 123456789 then how to create a get request for retrieving tickets related to the user

I tried this way and got always unauthorized as response

                $.ajax({
                 url: 'https://mysubdomain.zendesk.com/api/v2/requests.json',
                 beforeSend: function (request) {
                     request.setRequestHeader("Authorization", "Basic 
                    [email protected];123456789"); 
                     request.setRequestHeader('Content-Type', 'application/json');
                 },

        success: function (data) { 
            console.log( data);
                 },
       error: function (err) {
             console.log(err);
                 }
    })


Solution 1:[1]

As per the documentation here, the proper format for using tokens is {email_address}/token:{api_token}, as in [email protected]/token:6wiIBWbGkBMo1mRDMuVwkw1EPsNkeUj95PIz2akv. So looks like you need to add /token and the ; semicolon should be replaced with a : colon.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jimmy Long