Text of discuss.google.dev › t › node-js-request-module-problem › 4117 as Styx crawled it on Nov 20, 2026. The page may have changed since. Only its words are kept, without pictures or layout.

Open the live page

Node.js "request" module problem - Apigee - Google Developer forums

Node.js "request" module problem Google Cloud Apigee api-runtime anonymous8 January 3, 2018, 5:22pm 1 We are trying to implement a proxy using Node.JS. When we try to use the Node.JS “request” module, Apigee gives an error, which you can see from http://org-test.apigee.net . The code is very simple and similar to the sample ( node-samples/node/mashup/mashup.js at master · apigee/node-samples · GitHub ). var request = require(‘request’); var http = require(‘http’); var urlparse = require(‘url’); var util = require(‘util’); function sendError(resp, code, msg) { var o = { ‘error’: msg }; resp.writeHead(code, {‘Content-Type’: ‘application/json’}); resp.end(JSON.stringify(o)); } var svr = http.createServer(function(req, resp) { var request = require(‘request’); var options = { url: ‘ https://test.com/api/v2/asa ’, method:‘POST’, headers: { ‘Accept’: ‘application/json’, ‘Accept-Charset’: ‘utf-8’, ‘Api-Key’: ‘33769302e0812dsadasdadd’ }, json:true, body:{resource:{ group_name:‘testing’ }} }; request.post(options, function (err,res,body) { console.log(body) }); resp.writeHead(200, {‘Content-Type’: ‘application/json’}); resp.end(JSON.stringify(“{}”)); }); svr.listen(9000, function() { console.log(‘Node Mashup sample app is running on port 9000’); }); When I deploy my application, I use the following command: apigeetool deploynodeapp -u email -p password -o org -e test -n testapp -d . -m app.js Can you help me with this issue, or guide me to the people that can help me resolve the issue? anonymous8 January 3, 2018, 6:17pm 2 Hi @Uurtsaikh Jamsrandorj , did you include the request module as part of the dependencies in your package.json descriptor file? anonymous8 January 3, 2018, 6:25pm 3 Yes, I did.

Here is my package.json file. { "name": "test", "version": "0.0.0", "description": "test", "main": "app.js", "private": true, "dependencies": { "request": "2.x.x" } } anonymous8 January 3, 2018, 9:19pm 4 You wrote: Apigee gives an error, What error does Apigee give? Can you tell us exactly the error message you see? And when do you see it - after running which command or request? And where do you see it? anonymous8 January 3, 2018, 9:20pm 5 Hi, this answer is now marked “accepted”.

Have you solved your problem? what was the solution? If not, please provide additional information - specifically what error are you seeing? anonymous8 January 3, 2018, 10:29pm 6 No, I have not solved yet my problem anonymous8 January 3, 2018, 10:40pm 7 I think this is a compatibility problem, because the current version of the request module requires node version >= 4. https://github.com/request/request/blob/master/package.json "node": ">= 4" But, Edge currently supports Node.js 0.10.32. https://docs.apigee.com/api-services/content/understanding-edge-support-nodejs-modules You may consider to use alternative ways to make http request, e. g. ‘native’ http.request.

UPDATE: I’ve checked the GitHub repo for the request module. The last version that was supported on node 0.10.x was version 2.71.0 Therefore, to use the request module on Apigee Edge nodes targets, update your dependencies in package.json like so: "request": "2.71.0" https://github.com/request/request/tree/v2.71.0 anonymous8 January 3, 2018, 10:41pm 8 no. Can you help me to figure this out? anonymous8 January 3, 2018, 11:13pm 9 Hi Artem Petrosian , Thank you for your help.

It sounds like your right. Do you know which version of request module I should use? What I am trying to do is simple (call external HTTP RESTful web service). How would you do this one, if you were doing the same thing? I would like to use Node.js approach, and I am hoping that this option will give me more flexibility. Thanks, Tom anonymous8 January 3, 2018, 11:25pm 10 Hi , use below mentioned version for request module.

“request”: “1.x.x” Thanks Anil P anonymous8 January 3, 2018, 11:35pm 11 There are variety of different ways to call external service (Service Callout, JavaScript or Node.js). If you prefer Node way you can use build in http module. https://nodejs.org/docs/latest-v0.10.x/api/http.html#http_http_request_options_callback or use compatible version of request module (see updated answer). anonymous8 January 4, 2018, 12:08am 12 The body you are trying to post does not appear to be Json serialized as mentioned here. https://github.com/request/request#requestoptions-callback That could the problem.

Is the code working on your local setup ? anonymous8 January 4, 2018, 3:07am 13 You may also try express .. here is a snippet. var express = require('express'); var bodyParser = require("body-parser"); var request = require('request'); var app = express(); app.use(bodyParser.json()); app.use (function (error, req, res, next){ res.status(400).send(error.message); }); var router = express.Router(); app.use("/",router); router.get('/', function(req, res){ var _data = JSON.parse(JSON.stringify({ resource: { group_name: 'testing' } })); var _url = 'https://test.com/api/v2/asa'; request.post({ headers: {'content-type': 'application/json', 'Accept-Charset': 'utf-8', 'Api-Key': '33769302e0812dsadasdadd' }, url: _url, json: _data }, function (error, response, body) { if (!error) { console.log(body); } }); res.send("Hello"); }); app.listen(9000); ****************************************** { "name": "community", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "body-parser": "^1.18.2", "express": "^4.16.2" } } AI Suggested topics Topic Replies Views Activity request module not working with apigee tough it working in local Apigee api-runtime 3 107 January 12, 2018 Unable to recognize node modules Apigee api-runtime 11 239 September 6, 2016 can we use sync-request module in apigee?

Apigee api-runtime 2 85 June 29, 2016