I have a very simple AJAX code that's calling an AWS API gateway endpoint:
$.ajax({
url: 'https://omitted.execute-api.ap-southeast-2.amazonaws.com/test/rec',
type: 'post',
data: {
'zipcode': '1234',
'url': 'www.google.com'
},
dataType: 'json',
success: function (data) {
console.info(data);
}
});
And what I am getting back is:
Could not parse request body into json: Unrecognized token 'zipcode': was expecting ('true', 'false' or 'null')`
The data should be in JSON format so What am I doing wrong?
I have also tried:
$.post('https://omitted.execute-api.ap-southeast-2.amazonaws.com/test/rec',
{
'zipcode': '1234',
'url': 'www.google.com'
},
function(data, textStatus) {
//data contains the JSON object
//textStatus contains the status: success, error, etc
}, "json");
$.post('https://omitted.execute-api.ap-southeast-2.amazonaws.com/test/rec',
'zipcode=1234&url=www.google.com',
function(data, textStatus) {
//data contains the JSON object
//textStatus contains the status: success, error, etc
}, "json");
And they are returning the same result.