cancel
Showing results for 
Search instead for 
Did you mean: 

Not able to connect to HCP from AWS Lambda function

0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

nic_botha2
Explorer
0 Kudos

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