0

I would like to get some data from an external rest api. It's a post request. Following are the code which I've tried.

return new Promise(function (resolve) {
    var payload = JSON.stringify({ "data": [ "Requirement_Description": "xxx" }], "services": ["xxxx"], "labels": ["label_1"] });
    var options = {
        'url': 'https://myHost/xxx/api/model/predict',
        'method': 'POST',
        'body': payload,
        'json': true,
        'proxy': 'myProxy',
        'timeout': 10000,
        'followRedirect': true,
        'maxRedirects': 10
    };
    request.post(options, function (error, response, body) {
        if (error)
            resolve(error.message)
        else
            resolve(body)
    })
});

All the times, I am getting the error UNABLE_TO_VERIFY_LEAF_SIGNATURE. I've seen a question similar to mine, But in my case it's a post request and also passing some sort of raw data to the body while the post operation.

Libin C Jacob
  • 1,108
  • 12
  • 34
  • 1
    Possible duplicate of [Unable to verify leaf signature](https://stackoverflow.com/questions/20082893/unable-to-verify-leaf-signature) – Sven Mar 30 '18 at 08:15
  • @Svenskunganka that's not providing any solution for my proble. My requirement is a post operation with some sort of raw data passing through the body too. – Libin C Jacob Mar 30 '18 at 08:26
  • 1
    If you read the second, third and fourth answers to that question you'll most likely find a solution. Just because you perform a `POST` request rather than a `GET` request doesn't change the fact that you still need to perform the TLS handshake and verify the requested domain's certificates since the URL is HTTPS. – Sven Mar 30 '18 at 08:30
  • I am able to get the data through Postman – Libin C Jacob Mar 30 '18 at 09:12
  • Can you just try what solutions they've proposed? Postman uses the browser's CA pool, which includes intermediate CAs. – Sven Mar 30 '18 at 09:17

0 Answers0