how to write gateway script to extract parameters from input URL in APIC?

Hi,

I'm trying to fetch agent details based on agent_id which is coming from input headers. But this is not working.

I have written like this:

// Define modules
var sm = require('service-metadata.js');
var hm = require('header-metadata.js');
var apim = require('./apim.custom.js');

var LegacyAgentNumber = apim.getvariable('request.parameters.LegacyAgentNumber');
var requestId = apim.getvariable('request.parameters.id');
var channelId = apim.getvariable('request.parameters.channelId');
var channelName = apim.getvariable('request.parameters.channelName');
var sm_user = apim.getvariable('request.parameters.sm_user');

//To send as querry parameters
var queryString = '/GetAgentNumber(LegacyAgentNumber=%27'+legacyAgentNumber+'%27)';

apim.setvariable('queryString', queryString);
apim.setvariable('requestId', requestId);
apim.setvariable('channelId', channelId);
apim.setvariable('channelName', channelName);
apim.setvariable('sm_user', sm_user);

here is the backend url which i configured in Path:

/agency/books/book/agents/{agent-id}/contact-information

0 1 859
1 REPLY 1

The code you have is not for Apigee

For Apigee you could use the out of the box ExtractVariables policy to extract information from the request, along with AssignMessage policy to configure a new request object using the extracted values