Accessing the API Console
From the Portal dashboard you can get to the API console by selecting a recent tab or clicking on "NEW TAB" within the widget. Once the console loads, you will notice a list of API resources on your left, along with a prompt for you to "SELECT A CONTEXT".
What is an API Console Context?
Every interaction with the OrderCloud API requires a user context. Each contributing Portal user has their own unique context that is defined by their relationship and level of access to the marketplace. The API Console also allows Portal users with impersonation access to select a more specific core user context - meaning they are able to interact with the OrderCloud API as if they were a user within the marketplace.
Since we haven't created any core users at this point, we will be using your Portal user context which should be that of an owner.
Select Your First Context
Click "SELECT A CONTEXT". This will present a list of your available marketplaces. Choose the marketplace that we created in the last article. At this point, the context selector should close and you will automatically be authenticated using the FullAccess API Role provided to you as the owner.
Explore Your Region and Environment
Directly below the context selector, you will notice an expandable panel containing information about which region your context selection is utilizing, as well as information regarding the current context [user] who is making requests via the Portal interface. If you have simply clicked on a Marketplace, you will be making requests as your personal Portal user. If you have selected a specific user from the context selector, you will notice this interface clarifies that you are making requests as the selected user.
Validate Your Context
Navigate down to Me and My Stuff > Me API resource on the lefthand navigation. Select it and you should see the toolbar at the top change to "Get the currently authenticated user". Click the "SEND" button and look at the data that comes back. It should look something like this:
1{2 "Buyer": null,3 "Supplier": null,4 "Seller": {5 "ID": "xxxxxxxxxxxxxxxxxx"6 },7 "ID": "348D36CF-C5FB-45A3-A50D-04962AA26702",8 "Username": "24E98C61-3D28-45B4-8A98-9D91DB449E4C",9 "Password": null,10 "FirstName": "Default User",11 "LastName": "Default User",12 "Email": null,13 "Phone": null,14 "TermsAccepted": "2021-02-08T20:51:14.947+00:00",15 "Active": true,16 "xp": null,17 "AvailableRoles": [],18 "DateCreated": "2021-02-08T20:51:14.947+00:00",19 "PasswordLastSetDate": "2021-02-08T20:51:14.947+00:00"20}
This is what we call a "Default User" - it is essentially an admin user that will have the same level of data access as your Portal user. Don't be alarmed if AvailableRoles
is empty - as the owner of the organization it is implied that you have FullAccess
.
Portal User Context and Default Users
The default user you are authenticated as right now does not actually exist in the system, your marketplace is brand new and essentially empty. If you scroll up on the left-hand resources menu to click on Seller > Admin Users which opens the "Get a list of admin users" request. Click "SEND" and you will see an empty list response like this:
1{2 "Meta": {3 "Page": 1,4 "PageSize": 20,5 "TotalCount": 0,6 "TotalPages": 0,7 "ItemRange": [8 1,9 010 ]11 },12 "Items": []13}
In other words, you are not actually interacting with the OrderCloud API as you would in a normal implementation. In order to remedy this, we must first create some core users and establish a definition of how they can interact with your marketplace.
Still have questions?
Ask in our Community Channel