Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (19.1k points)

I'm trying to add a POST HTTP method to my AWS API Gateway. I'm using SAM framework with Python.

I find that there is a difference in the "body" of the response when it is generated from my desktop (curl or postman) and the AWS API Gateway 'TEST'

Right now, the "POST" command only prints the 'event' object received by the lambda_handler. (I'm using an object to store the event as you can see below)

def add(self):

    response = {

        "statusCode": 200,

        "body": json.dumps(self._event)

    }

    return response

When I'm using the 'TEST' option of the API Gateway console, with the input:

{"username":"xyz","password":"xyz"}

I receive the following output:

{

 "body": "{\"username\":\"xyz\",\"password\":\"xyz\"}",

<the rest of the response>

}

However, when I'm sending the curl (or postman) request:

curl --header "Content-Type: application/json"   --request POST   --data '{"username":"xyz","password":"xyz"}' <aws api gateway link>

I get the following response:

{

"body": "eyJ1c2VybmFtZSI6Inh5eiIsInBhc3N3b3JkIjoieHl6In0="

<the rest of the response>

}

Why do you think there is a difference between the two tests?

1 Answer

0 votes
by (44.4k points)

Your Authentication credentials are automatically Base63 encoding when Curl and Postman are used.

The responses will be the same while the latter response is a Base64-encoded token of the first response.

Related questions

0 votes
1 answer
Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...