Skip to Content

Not able to connect to HCP from AWS Lambda function


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://'; 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.



Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Jul 14, 2017 at 12:07 AM

    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.



    Add comment
    10|10000 characters needed characters exceeded