如何在IBM Bluemix APIConnect中使用gatewayscript调用https POST方法

如何在IBM Bluemix APIConnect中使用gatewayscript调用https POST方法,https,ibm-cloud,urlopen,apiconnect,Https,Ibm Cloud,Urlopen,Apiconnect,我正在尝试使用IBM Bluemix(API Connect)内的网关脚本调用Bluemix内的另一个API或任何其他HTTPS post方法,代码如下: var urlopen = require('urlopen'); var options = { target: 'https://pokemons.mybluemix.net/api/pokemons/1', method: 'POST', headers: {},

我正在尝试使用IBM Bluemix(API Connect)内的网关脚本调用Bluemix内的另一个API或任何其他HTTPS post方法,代码如下:

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');
      }
    });
  }
});
但我得到了以下错误:

{
  "httpCode": "500",
  "httpMessage": "Internal Server Error",
  "moreInformation": "URL open: Cannot create connection to 'https://pokemons.mybluemix.net/api/pokemons/1', status code: 7"
}
看起来SSL连接存在一些问题。如果是这样,我如何在IBMBlueMixAPI Connect中获取默认沙盒目录的SSL详细信息?或者,如何对上述示例URL进行HTTPS POST调用?

自5.0.6版起:

转发SSLProxy(和加密)将替换为SSLClient。这些新配置文件支持临时密码(DHE和ECDHE)、完全前向保密和服务器名称指示(SNI)扩展。请注意,DataPower SSLServerProfile中的DHE密码使用2048位DH参数(作为服务器)并接受1024位DH参数(作为客户端)

为了让特定示例使用HTTPS处理API Connect,您需要指定sslClientProfile

例如:

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"}

};
自版本5.0.6起:

转发SSLProxy(和加密)将替换为SSLClient。这些新配置文件支持临时密码(DHE和ECDHE)、完全前向保密和服务器名称指示(SNI)扩展。请注意,DataPower SSLServerProfile中的DHE密码使用2048位DH参数(作为服务器)并接受1024位DH参数(作为客户端)

为了让特定示例使用HTTPS处理API Connect,您需要指定sslClientProfile

例如:

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"}

};