【问题标题】:IBM API Connect Gateway script is not being executedIBM API Connect Gateway 脚本未执行
【发布时间】:2021-03-10 20:45:57
【问题描述】:

我已将我的 API DESIGN 配置为访问本地 python 应用程序http://127.0.0.1:9999/get_batch_filters 即使组装窗口是空白的,这也可以正常工作。

我注意到网关脚本没有被执行,也没有错误。 这个脚本应该抛出错误,但它会命中本地 python api 并且不管网关脚本是否存在都可以工作。

网关脚本:

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');
      }
    });
  }
});

【问题讨论】:

    标签: ibm-cloud api-gateway urlopen apiconnect


    【解决方案1】:

    在添加网关脚本时使用操作开关它会给你正确的响应 -

    【讨论】:

      猜你喜欢
      • 2017-10-10
      • 1970-01-01
      • 1970-01-01
      • 2016-07-21
      • 1970-01-01
      • 2020-10-24
      • 1970-01-01
      • 2012-09-18
      • 2020-03-14
      相关资源
      最近更新 更多