Calling UserGrid Within Edge Proxy

Not applicable

I'm new to Apigee, but haven't been able to find an answer to this question through any searches. I'm trying to create a mashup proxy that combines data from a public API and from data held within Apigee's BaaS Usergrid.

To date, I haven't been able to figure out how to query UserGrid within Edge. I've got a JavaScript proxy, much like the one in this mashup example from Apigee, but I get the "Usergrid is not defined" JavaScript error. The Mashup sample from Apigee says that the JavaScript Object Model gets loaded, but I'm guessing the BaaS object model is not. Can I simply add a script reference to the Object Model in the policy XML file?

Solved Solved
0 1 472
1 ACCEPTED SOLUTION

The usergrid SDK won't be available in that JavaScript policy (as you've found) edit: By default, but you can add it. See Below.. Additionally: it would be possible to use that with a node.js proxy. Alternatively with a 'regular' proxy and a JavaScript policy, you can use the httpClient object (described here) http://apigee.com/docs/api-services/cookbook/implementing-http-clients-javascript to make the API calls directly without using the usergrid SDK.

EDIT! Alternatively, and to do things the way you want to.. add the usergrid.js to your resouces and use the includeURL element of the javascript policy. see docs here: http://apigee.com/docs/api-services/reference/javascript-policy -- I haven't tested that it works, I always just use httpClient for simplicity.. should be an easy thing to verify though.

View solution in original post

1 REPLY 1

The usergrid SDK won't be available in that JavaScript policy (as you've found) edit: By default, but you can add it. See Below.. Additionally: it would be possible to use that with a node.js proxy. Alternatively with a 'regular' proxy and a JavaScript policy, you can use the httpClient object (described here) http://apigee.com/docs/api-services/cookbook/implementing-http-clients-javascript to make the API calls directly without using the usergrid SDK.

EDIT! Alternatively, and to do things the way you want to.. add the usergrid.js to your resouces and use the includeURL element of the javascript policy. see docs here: http://apigee.com/docs/api-services/reference/javascript-policy -- I haven't tested that it works, I always just use httpClient for simplicity.. should be an easy thing to verify though.