Hotline Logo freshchat

Start a new topic

Can't make GET request

I'm trying to make a GET request to external API with Ajax, mentioned url in 'whitelisted-domains', but API is not getting data, i received Error 502 Bad Getaway, Error in establishing connection. It seems freshdesk environment blocks it somehow.


2 people have this problem

Hi Michael,


Can you share the code snippet we can suggest.


Thanks

Mahesh

Yea, of course

js
(1.49 KB)

Hi Michael,


The URL is invalid, it throws 404 on my browser and using freshdesk proxy ($request.get) I get 502.  This is because we send 502 on error.


Check the URL u hit https://api.reps.ai/


image



Thanks

Mahesh

Hi Mahesh

thank you for your answer

As you can see in my code i am trying to access a different URL and not the one you mentioned.

The code is calling url: https://api.reps.ai/accounts/kasamba/tickets/analyze

You can validate this URL and it works just fine.

Can you help?


Hi Michael,


Internally the this.$request.get uses the node request, if u try doing a 'get' on the URL you get a error.



$ node

> let r = require('request');

undefined

> r.get('https://api.reps.ai/accounts/kasamba/tickets/analyze', function(err, resp, data){ console.log('error - ', err); console.log('resp - ', resp); console.log('data - ', data);})


> error - { Error: unable to verify the first certificate

    at Error (native)

    at TLSSocket.<anonymous> (_tls_wrap.js:1060:38)

    at emitNone (events.js:86:13)

    at TLSSocket.emit (events.js:185:7)

    at TLSSocket._finishInit (_tls_wrap.js:584:8)

    at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:416:38) code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' }

resp - undefined

data - undefined


Looks like there is some cert problem, Please check ur end.


Thanks

Mahesh


Even I have this problem with Freshdesk Developer v2 Request API. The domain is in the whitelisted domain but the response is 

{
errorSource :"APP"
headers : {}
response : "Error in establishing connection"
status : 502
}

 Please help me solve this issue.


1 person likes this

Hi Anish,


Please share your code snippets and app details to debug.


Regards,

Janani V.

Hello, I have the same issue of 502 connection error.


 

var options = {
                            "headers" : {
                              "Content-Type": "application/json"
                            }
        };              };
                        var url = "https://www.mocky.io/v2/5ba09eb03500004f005bb8e4";
                     
                        client.request.get(url, options)
                        .then(function(data) {
                          console.log('success' + data.language);
                        }, function(error) {
                          console.log('danger' + JSON.stringify(error));
                        }); 

 Here is my code snippet I am using mock API as my local api is also giving the same error. Please help me on this issue. Also if there is any way to call local api (non https) using fdk app.

Thanks

Prankur

I got the same error, have you resolved this issue?

I got the same error

Login or Signup to post a comment