IBM API Connect Gateway script is not being executed

1.1k views Asked by At

I have conifgured my API DESIGN to hit a local python application http://127.0.0.1:9999/get_batch_filters even with the assemble window being blank this works fine.

I have noticed that the gateway scripts are not being executed, also there are no errors. This script should throw error but instead it hits the local python api & works regardless gateway script is present or not.

The image shows that instead being pointed to an external api in gateway script - it still hits the local api

Gateway script:

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

There are 1 answers

0
Vishal Ghadage On

Use oprational switch while adding gateway script it will give you proper response -

enter image description here