on 07-13-2017 11:37 PM
Hi,
I'm trying to POST data from AWS Lambda function to a OData service created in HCP,
I'm passing the same path i used for POSTMAN, in AWS Lambda function.
I'm able to successfully POST using POSTMAN but not through AWS Lambda.
I have used Alexa Skill kit in Blueprint.
I'm getting error: Process exited before completing request
https is not defined
My function Code is as below:
exports.handler = function(itemName){ var host = 'https://<Account>trial.hanatrial.ondemand.com/'; var authStrIoT = 'basic_authorization("USERID", "PASSWORD")';
var body = JSON.stringify({ "ID" : 1, "CATEGORY" : itemName }) ;
var request = new https.request( { hostname: host, path: Copy pasted Path used in POSTMAN,
method: "POST", headers: { "Content-Type": "application/json; charset=utf-8", 'Accept': '*/*' } }) ; request.end(body) ; request.on('response', function (response) { console.log('STATUS: ' + response.statusCode); console.log('HEADERS: ' + JSON.stringify(response.headers)); response.setEncoding('utf8'); response.on('data', function (chunk) { console.log('BODY: ' + chunk); }); }); };
Any inputs on this would be helpful.
Thanks,
Raghav
Could be you are missing
var https = require('https');
but difficult to say from looking at just the snippet. Also make use of the CODE formatting when posting.
Regards,
Nic
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.