apigee api mock response

madan1981
Participant I

Hi,

Can you please guide, does Apigee edge API provide mockup response instead of connecting directly with backend services? If yes, can you please share some reference document?

Thanks

Madan

0 3 1,237
3 REPLIES 3

@Madan kumar

Apigee does not provide mockup responses out-of-the-box. You will need to build that logic in your API proxy.

For example: You can send a query param mock=true; add a routerule to check the value of mock and not route to the target if mockup is required.

Assign Message policy can be used in the response flow for sending out mock responses

You can use javascript to set your mock responses; you can also build some logic in javascript to generate random values to include dynamic nature to the responses.

Apigee does not provide an "automatic" way to mock responses.

There are some options.

Not applicable

You can create proxy using hosted target option in apigee. There you will see Quick start: use "Hello World" sample option. You can select that and get a hello world proxy to use as direct api or backend to another api. If you want to get different responses then inside the proxy change the 'Hello, World!' script code to below code. This will send you the response body that you send in the request body.

var http = require('http');


console.log('node.js application starting...');
console.log(process.env);


var svr = http.createServer(function(req, resp) {
  resp.writeHead(200);
  req.pipe(resp);
});


svr.listen(process.env.PORT || 3000, function() {
  console.log('Node HTTP server is listening');
});