Getting 426 error status

Hi Team,

I am tying to send get request using API in iparams page, But i am receiving the response with 426.

FYI please check below code and response provided.

 function apiCheck(client, domain_val, key_val) {
        console.log(key_val.length);
        console.log("i am in api check func");
        var url = `https://${domain_val}/v2/agents`;            
        var headers = {
            "Authorization": "Bearer " + key_val
        };           
        var options = {
            headers: headers
        };           
        client.request.get(url, options).then(function () {               
            
        }, function (error) {              
            console.log(error);
            handleError(error);
        });
    }

Hi Tipuranjali,

I just wanted to confirm that your domain_val is api.freshchat.com and not the respective domain of the person using the app. As mentioned in the documentation here, the call needs to be made to the domain https://api.freshchat.com. Also I noticed that in your then block, the data function does not take an argument while it is supposed to. You can just add that and your code should look something like what is shown below

client.request.get(url, options).then(
        function (data) {               
          //perform action with data   
        }, 
        function (error) {              
            console.log(error);
            handleError(error);
        });
2 Likes