Using Postman to work with the Genesis API
Postman is a useful tool that can help you test, and then experiment with, the Genesis API. You can use Postman with on-prem or ESHA Cloud hosted instances of the Genesis API and it’s a great way to become familiar with the different Genesis API endpoints and their capabilities.
What you’ll need:
Postman (which you can get from here)
If you're using an on-premises installation of the Genesis API, you'll need the URL where the endpoints were installed. Contact your Network Administrator or whomever installed the API for that information.
The URL will typically look like:
https://mylocalnetwork.com:<portnumber>
where <portnumber> is something like 8080 (or another open port on your network)
If you're using the Genesis API hosted on ESHA Cloud, you will need the onboarding email that was sent when the API was set up for you. That email will contain the specific URL you will connect to as well as the Basic Authentication credentials you will need. If you did not receive that email, contact ESHA Support and request it be resent.
Create a Workspace and a Collection
Install and launch Postman
Click “Workspaces” in the upper left of the window to open the Workspaces menu
Click “+New Workspace”
Name the workspace “Genesis API Testing”
Click the “New” button, select “Collection” from the dialog that appears, and name your collection “Genesis API 4.x”
If your local network needs authorization credentials to connect to the provided URL, or if you are using the Genesis API hosted in ESHA Cloud, follow the steps in the “Configure Authorization” section. If not, skip ahead to the “Send a Request” section.
Configure Authorization
In the left pane, where the “Genesis API 4.x” Collection is visible, hover over its name and click the ellipsis that appears
Click “Edit”
In the main pane, click the “Variables” tab
Where it says “Add a new variable” enter “GenesisApiId” (without the quotes)
Under “INITIAL VALUE” enter your ID from the onboarding email or from your Network Administrator. Be certain the “CURRENT VALUE” also includes your ID.
Add another variable called “GenesisApiPw” (without the quotes)
Leave “INITIAL VALUE” blank and enter your password in the “CURRENT VALUE” field
Select the “Authorization” tab
If you are using the Genesis API hosted in ESHA Cloud, change the “Type” to “Basic Auth”, or whatever authorization is required for your network
For “Basic Auth”, in the “Username” field, type {{GenesisApiId}}
Click the “Show Password” checkbox
In the “Password” field, type {{GenesisApiPw}}
Click the “Save” button in the upper section of the main pane
Create and Send a Request
For the purposes of this guide, we will be using https://mylocalnetwork.com:8080 as the URL. Replace this with your specific URL from the start of this guide.
In the left display pane, expand “Genesis API 4.x” and click “Add a request”
Enter “ListUnits” for the name of the request
Change “GET” to “POST”
Where is says “Enter the request URL” enter the following:
https://mylocalnetwork.com:8080/rest/FoodQueryService.svc/ListUnits
Click on the “Body” tab below the URL
Click on the “raw” radio button
Ensure that the drop down to the right of “GraphQL” shows “Text” and if it does not, change it to “Text”
In the text box where you see “1” displayed, enter the following request:
request={}
Click the “Save” button to save the request in your Workspace
Click the blue “Send” button to send the request to the endpoint
You should get a list of units in the bottom pane with a “Status” of “OK 200”
This same pattern can be used for any of the endpoints you wish to test. For some endpoints (e.g. ListUnits, ListNutrients, etc.) an empty request (request={}) is valid. For most it is not. See the documentation for all endpoints for sample requests that can be copy/pasted into Postman and used for testing.
You can find more information on Postman and its capabilities here.