I'm calling AWS APi Gateway from node, using the following options:
var post_options = {
host: 'myurl.execute-api.us-west-2.amazonaws.com',
port: '443'
path: '/staging/api',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(post_data)
}
};
The call is made in the following way:
http.post(post_options, post_data, function(res){
res.setEncoding('utf8');
res.on('data', function(chunk) {
console.log(chunk);
});
});
The response I get back is:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The request could not be satisfied</TITLE>
</HEAD><BODY>
<H1>ERROR</H1>
<H2>The request could not be satisfied.</H2>
<HR noshade size="1px">
Bad request.
<BR clear="all">
<HR noshade size="1px">
<PRE>
Generated by cloudfront (CloudFront)
Request ID: Yl1rUhK7Bmaq57ckHvK1E32tqNqDs4GC078yek3_23_RMefXUGJAdA==
</PRE>
<ADDRESS>
</ADDRESS>
</BODY></HTML>
name: undefined
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The request could not be satisfied</TITLE>
</HEAD><BODY>
<H1>ERROR</H1>
<H2>The request could not be satisfied.</H2>
<HR noshade size="1px">
Bad request.
<BR clear="all">
<HR noshade size="1px">
<PRE>
Generated by cloudfront (CloudFront)
Request ID: nJ3dotCRum8XudR6v0PinqzDjjPCX3N5TmoM2fNQSJK9BLn8jJEWqg==
</PRE>
<ADDRESS>
</ADDRESS>
</BODY></HTML>
I think, I'm getting "Bad request" because I did not pass any authentication information to my call. What is the proper syntax to add such auth information?
via Eugene Goldberg
No comments:
Post a Comment