In this article we will:

  • Import an API into API Gateway
  • Test the imported API
  • Deploy an API
  • Test an API deployment

Import and Configure the sample Pets API

1. Login to AWS account. Using Services drop down in top menu, click on API Gateway under Networking and Content Delivery

2. If creating API  for first time then click Get Started

3. Click OK on the popup to proceed

4. On the Create new API form, you’ll see that Example API is selected by default, and there’s an example API defined in the editor. We’ll use this API for the rest of our tutorial, so begin the API creation process by clicking Import.

5. Once API is created it will show this message

6. You will find GET and POST methods for pets and GET method for {petid} already created.

 

Test this sample Pets API

1. Click on POST under /pets. Click Test

2. On the “/pets – POST – Method Test” page, enter the below json code in request Body and click Test. This will add pet type and its cost in database.

{“type”: “dog”,”price”: 249.99}

 

3. The results will show up like below with success message and logs

 

Deploy the sample Pets API

1. To access this API using POSTMAN or Azure App, you’ll need to deploy the API to a stage. You can do this via the Actions menu, which offers the Deploy API option. Provide appropriate values and click Deploy to proceed.

 

Test the Deployed API

When the API has successfully deployed, you’ll be redirected to the Test Stage Editor. You can test the API to see if it is deployed correctly.

At the top of the Test Stage Editor window is a blue banner with your Invoke URL. This is the URL used to invoke the GET endpoint of your API.

Click on the link to submit the GET / method request in a browser. This should result in the following success response:

You can make a call based on {petid}. In the Stages page, expand the tree under Test. Click GET under /pets/{petId}. Copy the url

https://ev2zkpeo3l.execute-api.us-east-2.amazonaws.com/Test/pets/{petId} and replace {petId} by 1 and execute the URL-

https://ev2zkpeo3l.execute-api.us-east-2.amazonaws.com/Test/pets/1

 

So now we have fully functional API that is managed by AWS API Gateway.

 

Step 4 – Create the Custom Authorizer