Using hosted target server to install firebase admin sdk, below is the error we are getting :
<html><head> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <title>500 Server Error</title> </head> <body text=#000000 bgcolor=#ffffff> <h1>Error: Server Error</h1> <h2>The server encountered an error and could not complete your request.<p>Please try again in 30 seconds.</h2> <h2></h2> </body></html>
1)Tried using java callout but there are 52 jars & unable to do so in apigee.
2)Using Python we are unable to install the required library.
3)Using Node js we are unable to import the Firebase-admin module using management calls.
Kindly provide an solution to use firebase-admin sdk in apigee
This example connects into Firebase/Firestore via nodejs and Hosted Targets.
It does not use the Google SDK for nodejs. I looked into using it, but I didn't like the SDK - it seemed too bloated for my purposes. I just wanted a simple read connection, and the REST API for Firestore is documented. So I used the REST API and just constructed requests manually.
The code is pretty simple, if you know nodejs and the nodejs request module .
function getOneOrMore(request, response) { let uriPath = sprintf('projects/%s/databases/(default)/documents/users', getServiceAccount().project_id); var endpoint = request.params.name ? urljoin(baseEndpoint, uriPath, request.params.name) : urljoin(baseEndpoint, uriPath); var requestOptions = { url: endpoint, method: 'get', headers : { authorization: 'Bearer ' + gAccessToken, accept: 'application/json' } }; logWrite('GET %s', request.url); httpRequest(requestOptions, function(error, httpResponse, body){ if (error) { response.status(500).send(body); return; } response.status(200) .send(JSON.stringify(xform(JSON.parse(body)), null, 2)); }); }
I'm getting a "500 server error" when I deploy that code. I am able to successfully add test data to my firestore DB with it, and deploy to my test instance, but when I try to hit it via the deployed proxies I get the 500 error.
User | Count |
---|---|
5 | |
2 | |
2 | |
1 | |
1 |