Hi,
I'm trying httpClient in JavaScript policy to make mock target call with below snippet
function onComplete(response, error) { print("inside onComplete",response); print("error",error); if (response) { context.setVariable('example.status', response.status); } else { context.setVariable('example.error', 'Woops: ' + error); } } print("before hitting mock server"); // Function callback allowed as an argument. httpClient.get("http://mocktarget.apigee.net/json",onComplete);
Callback is not happening with above snippet, Can you please help on this?
If i make a call using waitForComplete() then i was able to see the response. The snippet used in this case is below
var ex1 = httpClient.get("http://mocktarget.apigee.net/json"); ex1.waitForComplete(); if (ex1.isSuccess()) { response1 = ex1.getResponse(); print("response after waitForComplete",response1.content); context.setVariable('example.status',response1.status); } else { error = ex1.getError(); context.setVariable('example.error','Woops: ' + error); }
Hi Dino,
its a SaaS version.
Answer by Kuldeep Bhati
·
Mar 26, 2019 at 11:37 AM
I experienced the same behavior when I tried this code on my org, however when I tried on other newly created evaluation org, it works! It seems the update - https://docs.apigee.com/release/notes/180608-apigee-edge-public-cloud-release-notes has not been pushed to your org as well as mine, I suggest you to get in touch with Apigee Support to fix this.
Hi Kuldeep,
Thanks for your reply, I had a try with new one as well but not able to view callback triggered
JavaScript Callout Policy 2 Answers
Parse json payload and change specific values according to pattern search 1 Answer
MessageLogging Policy or new JavaScript file 3 Answers
Getting some error if my variable name contains "hiphen" in the name inside javascript. 1 Answer
Unit testing of JavaScript Policy 1 Answer