0

I am working on setting up JavaScript code to run a POST request against an AWS endpoint that is set up. It requires authentication to access, and I am able to test and get data back using postman where I set the Auth type to AWS Signature and set my Access and Secret Keys. I know that putting them in code is bad practice, but I am okay with it at least in the short term for testing new code that needs what is returned from the request (or if someone could outline the proper way to do so that would be great too).

The endpoint allows me to hit a AWS Neptune db that is set up and gremlin is being used to query it. Here is the post URL that currently works in Postman (obviously with the main part obfuscated:

https://asfgawr123.us-west-423.amazonaws.com/v0/lambda?gremlin=g.V().has("item","1956").values("title")

halfer
  • 19,824
  • 17
  • 99
  • 186
Jicaar
  • 1,044
  • 10
  • 26

1 Answers1

1

I discovered the answer thanks to a postman ability I wasn't aware of where you can see the code of the request in many different formats.

enter image description here

I used the jquery format which came out to this:

var settings = {
  "url": "https://asfgawr123.us-west-423.amazonaws.com/v0/lambda?gremlin=g.V().has(\"item\",\"1956\").values(\"title\")",
  "method": "POST",
  "timeout": 0,
  "headers": {
    "X-Amz-Date": "20200618T212931Z",
    "Authorization": "AWS4-HMAC-SHA256 Credential=<credentialstring>, SignedHeaders=host;x-amz-date, Signature=<SignatureString>"
  },
};

$.ajax(settings).done(function (response) {
  console.log(response);
});
Jicaar
  • 1,044
  • 10
  • 26