Unable to send request to on-premise product using request API

Hi,

We want to integrate our internal product(on premise) with Freshservice. While using the request API to connect to our server which is configured with self signed SSL certificate, the following error response is received.

Response Received:
{“status”:502,“headers”:{},“response”:“Error in establishing connection”,“errorSource”:“APP”,“attempts”:1}

logs.rar (971 Bytes)

We are unable to connect with the request API and used fetch API to get data from our product with reference to the following link.
[Can you break Marketplace guidelines (a little bit)?]

However, as per Marketplace guidelines, usage of fetch API is restricted. Could you please suggest some other solutions to resolve the problem ?

Thanks,
Baskar.

Hello Baskar,

Welcome to community.

Yes, you should use Request method to make third party API calls.

Let me know if you are facing any difficulties using this method, I would be happy to help you further.

Hi Yusra,

Thank you for the reply. Why can’t I connect to my server which is configured with Self Signed Certificate using the Request API? Should I do any additional configurations to communicate with my server (with self signed SSL certificate)?

Logs for Reference:

FDK 31988: (proxy.js) Parsed https://host-name:2367/API/Login?methodToCall=list as {“protocol”:“https:”,“slashes”:true,“auth”:null,“host”:“host-name:2367”,“port”:“2367”,“hostname”:“host-name”,“hash”:null,“search”:“?methodToCall=list”,“query”:“methodToCall=list”,“pathname”:“/API/Login”,“path”:“/API/Login?methodToCall=list”,“href”:“https://host-name:2367/API/Login?methodToCall=list”}
FDK 31988: (proxy.js) Making proxy call with options as {“url”:“https://host-name:2367/API/Login?methodToCall=list",“method”:“get”,“maxAttempts”:1,“retryDelay”:0,"timeout”:5000}
FDK 31988: (proxy.js) Proxy came back with error as self signed certificate, body as
FDK 31988: (coverage-util.js) Writing coverage.

Any suggestions would be helpful!

Thanks,
Baskar

Can you please share the piece of code where you are making the call?

//Sample URL=https://host-name:2367/API/Login?methodToCall=list

function fetchData(url) {
	return new Promise((resolve,reject)=>{
		client.request.get(url, {})
		.then(
			function(data) {
				//...
				resolve(JSON.parse(data.response));
			},
			function(error) {
				//...
				reject(error);
			}
		);
	});
}

The request function seems good.

To debug it further:

  • print the data/error in success/error function
  • make sure you are sending all the parameters correctly.
  • note the time this particular API is consuming as Request method has a default timeout of 6 seconds. Check this time at Postman.

Hi Baskar,

The first thought I had when I saw your question is if the certificate is also installed in the machine which is running the FDK. The issue with self certified SSL servers is that the certificate is (most of times) only installed in a single machine. Maybe it could be the issue. Could you confirm if the certificate is present in both of the machines keychains? If this doesn’t work, do reply and we will figure something out together.

Hi, @Baskar.

For custom apps, i.e., apps intalled only on your account, you will not publish it on marketplace, it’s possible to use third party libs for requests. So you can try use unirest
In this lib, it’s possible to disable the certificate verification:

Request.strictSSL(Boolean)
Sets strictSSL flag to require that SSL certificates be valid on Request.options based on given value.

So declare the lib on manifest.json and try the code:

var unirest = require("unirest");
var req = unirest("GET", "url")
    .headers({
        Accept: "application/json",
    })
    .strictSSL(false)
    .end(function(res) {
        if (res.error) {
            console.error(res.error);
        } else {
            console.log(res.raw_body);
        }
    });
1 Like