Skip to content

Testing the endpoints with Postman

Vicente Pastor edited this page Jun 27, 2024 · 3 revisions

We have attached a postman collection in this repository to showcase how to perform the calls to an AWS App Runner instance that is running this service.

Requirements

You can get postman from their official website.

Importing the collection

With postman, you can then import the circuloos.postmanCollection.json in this repository.

You will either want to download the file by clicking the download button:
image

Or you can get a URL directly to the file on GitHub by clicking on the raw button when viewing the file:
image

To import the file so, you will want to open postman, then on the top left click on File then click on Import..., or alternatively use the Ctrl+O default key bind to import:
image

You can then select the file you downloaded, or paste the URL of the raw file on GitHub (example URL: https://raw.githubusercontent.com/alastria/Circuloos/main/circuloos.postmanCollection.json?token=GHSAT0AAAAAACSCHFJ2ITWIEZS2T4O5PXFWZSW65NA):
image

Postman will then automatically import the collection, and it will now be usable by you to test:
image

Setting up the collection

Before you are able to execute any tests, you will have to get an API Key from us.
If you already have an API Key, then in postman, within the collection itself, you should navigate to the variables tab: image

You will see 3 variables:

  1. host - the server postman will send the requests to
  2. api-key - The api key we gave you to authenticate to the instance we deployed in AWS App Runner
  3. erc721structDataAddress - The address of a deployed AlastriaERC721StructData contract that we will interact with

You will want to paste your API Key directly into the current value of the api-key variable like so: image

Dont forget to save the change you just made either with Ctrl+S or by pressing the Save button! Once you have done this, the collection is set up, and you can start running the tests.

Tests

There are a total of 5 requests prepared in this postman collection:

  1. Deploying the contract
  2. Minting a new token with ID 0 and some data
  3. Retrieving the data for token ID 0
  4. Updating the data for token ID 0
  5. Burning the token with ID 0

Whilst all 5 requests are provided, there are only 2 tests for you to run.

Test 1 - Minting a new token with ID 0 and some data

You will be running the POST request named Mint token with ID 0.
This should give you a transaction response when running it.

To run it, you will first have to open the request by clicking on it:
image

Once you have it open, navigate to the Body tab within the request.
You will be able to see an example as to how you can create the token with a struct value:
image

Feel free to change the value in between the double quotes (") to something else.
Once you are ready, you can run the request by pressing the Send button:
image

If all went well, you should be able to see a result on the bottom of your screen.
This result provides you with the transaction receipt from the blockchain after executing the smart contract: image

You can see in the image that there is a Status: 200 OK on the response.
If you have it saying Status: 403 Forbidden, go back to Setting up the collection and make sure the API key is correct, with no additional spaces or characters, and that you saved the collection. Example of it saying Status: 403 Forbidden:
image

Test 2 - Burning the token with ID 0

You will be running the POST request named Burn token with ID 0.
This should give you a transaction response when running it.

To run it, you will first have to open the request by clicking on it:
image

Once you have it open, you can run the request by pressing the Send button:
image

If all went well, you should be able to see a result on the bottom of your screen.
This result provides you with the transaction receipt from the blockchain after executing the smart contract: image

You can see in the image that there is a Status: 200 OK on the response.
If you have it saying Status: 403 Forbidden, go back to Setting up the collection and make sure the API key is correct, with no additional spaces or characters, and that you saved the collection. Example of it saying Status: 403 Forbidden:
image