Search code examples
node.jsamazon-web-servicesapiamazon-lex

Make a POST Request to Amazon Lex from NodeJS


I have created a bot using Amazon Lex, Now I want to call the PostText API provided by Amazon Lex : https://docs.aws.amazon.com/lex/latest/dg/API_runtime_PostText.html using my NodeJS code.

I am using the following guide: https://virtualbrakeman.wordpress.com/2017/02/13/aws-rest-api-authentication-using-node-js/

The only difference in mine is a POST request.

What should be the 'payload' value in my case ?

I am getting the error : 403 Forbidden when I make the POST request, but I am able to run the same API using Postman.


Solution

  • I found out that in case of POST request the payload value should be as follows: '{"inputText":" -- value_of_inputText -- "}'

    One can also skip the whole calculation for creating headers and simply use npm aws-sdk package