Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

When using httpClient to create app key and secret via Management API I get isError() even when the key is created

I need to intergrate our custom Developer Portal with Auth0 and so at app creation. So I need the Client ID and Client Secret from Auth0 integrated with the APP credentials of Apigee.

Using the JS policy I always end up in exchange.isError() Even though the key is created

var url = 'https://api.enterprise.apigee.com/v1/organizations/' + organization + '/developers/' + developerEmail + '/apps/' + productName + '/keys/create';
var headers = { 
    'Content-Type' : 'application/json',
    'Authorization' : base64Credentials
};
var payload = '{ "consumerKey": "' + key + '", "consumerSecret": "' + secret + '" }';


var request = new Request(url, 'POST', headers, payload);
var exchange = httpClient.send(request);


exchange.waitForComplete();


if (exchange.isSuccess()) {
    var response = exchange.getResponse();
    context.setVariable('response.content', response.content);
}
else if(exchange.isError()){
    context.setVariable('response.content', 'Error'); 
}

I want to have more control then the callout policy offers but it seems that the exchange object doesn't contain error information when isError() is true.

documentation on management API: App keys: Developer | Edge APIs (apigee.com)

0 3 525
3 REPLIES 3