0
votes

I am trying to call another API inside Bluemix or any other HTTPS post method using a gateway script inside IBM Bluemix (API Connect) using the code below:

var urlopen = require('urlopen');
var options = {
            target: 'https://pokemons.mybluemix.net/api/pokemons/1',
            method: 'POST',
            headers: {},
            contentType: 'application/json',
            timeout: 60,
            data: {"Message": "DataPower GatewayScript"}

};

urlopen.open(options, function(error, response) {
  if (error) {
    // an error occurred during the request sending or response header parsing
    session.output.write("urlopen error: "+JSON.stringify(error));
  } else {
    // get the response status code
    var responseStatusCode = response.statusCode;
    var responseReasonPhrase = response.reasonPhrase;
    console.log("Response status code: " + responseStatusCode);
    console.log("Response reason phrase: " + responseReasonPhrase);
    // reading response data
    response.readAsBuffer(function(error, responseData){
      if (error){
        throw error ;
      } else {
        session.output.write(responseData) ;
        apim.output('application/json');
      }
    });
  }
});

But I am getting the following error:

{
  "httpCode": "500",
  "httpMessage": "Internal Server Error",
  "moreInformation": "URL open: Cannot create connection to 'https://pokemons.mybluemix.net/api/pokemons/1', status code: 7"
}

Looks like there is some issue with the SSL Connections. If so, how can I get the SSL Details for the default Sandbox Catalog in IBM Bluemix API Connect? Or, how can I make the HTTPS POST calls to the above sample URL?

1

1 Answers

3
votes

Since Version 5.0.6:

IBM API Connect 5.0.x

Forward SSLProxy (and Crypto) is replaced with SSLClient. These new profiles support ephemeral ciphers (DHE and ECDHE), perfect forward secrecy, and Server Name Indication (SNI) extension. Note that DHE ciphers in DataPower SSLServerProfile use 2048-bit DH parameters (as server) and accept 1024-bit DH parameters (as client).

In order for you specific example to work on API Connect using HTTPS you need to specify the sslClientProfile.

For example:

var urlopen = require('urlopen');
var options = {
            target: 'https://pokemons.mybluemix.net/api/pokemons/1',
            method: 'POST',
            headers: {},
            contentType: 'application/json',
            timeout: 60,
            sslClientProfile: 'webapi-sslcli-mgmt',
            data: {"Message": "DataPower GatewayScript"}

};