Now, add the master_token
as an environment variable.
The default formatting of cURL generated by postman is not valid with HTTP Client's cURL import feature.
To import cURL requests from Postman into HTTP Client connector, ensure `Follow original HTTP method` is switched on in cURL settings. Here's how you can verify this setting is turned on for you:
1. Click on settings icon for cURL code snippet.
2. Ensure your settings panel looks like the one shown:
Click here to download our collection for the Insomnia Http client
This will provide you with a local testing environment which allows you to very quickly run queries and mutations on your live data, before inspecting the results.
IMPORTANT!: You will be interacting with live production data and any changes will be permanent.
In your Insomnia Workspace click on the drop-down to import the above downloaded file:
Click on 'embedded tokens' followed by 'Manage Environments':
Then you can see that the base url is https://tray.io/graphql
If you are in the EU region, change the base URL to https://eu1.tray.io/graphql
If you are in the Asia Pacific region, change the base URL to https://ap1.tray.io/graphql
Then enter your master token (you can enter tokens from different accounts if you are using the Import / Export project APIs) obtained from the Embedded Dashboard (don't worry about the user_token error here - it will be rectified when you first use it):
One of the main benefits of using Insomnia is that it has dynamic environment variables.
With the Tray Embedded Insomnia library, we have set up a dynamic variable for user token such that when you run the 'Create User Access Token' mutation with a valid userID, the user token will then automatically be available for all queries and mutations that require it.
For example we can create a user token for a user and then get that user's authentications. Here you will see that you do not have to copy and paste the access token, because once it is created it is automatically pulled in to the 'Get User Authentications' endpoint:
The steps taken were:
Use the 'Get Users' query to obtain the userId of an End User
Paste that userId into 'Query Variables' for the 'Create User Token' mutation
'Send' to create the User Token
The User Token is then automatically available for all queries and mutations that require it.
Note that you can also switch between user and master token for queries that can use either.
Some queries have multiple data filtering and input options.
For example, with the 'Get Users' query you can get all users, filter by userId, get the first 5 users etc.
So for this endpoint we have created a fragment whereby we first specify fields we want to be returned. Then we can click on the request we want to make (e.g. Get user by ID) before clicking ‘send’:
Using a valid master or user token means that you are connected to the Tray Embedded API schema.
In Insomnia this means you can use 'ctrl + space' to bring up an auto-complete list of available fields to be returned:
Embedded API documentation with all queries and mutations can be found here: https://developer.tray.io/openapi/embeddedapi-introduction/
The Tray GraphQL Playground is a handy resource for beginning to explore the Tray Embedded API and try out different queries and mutations.
For the most user-friendly testing environment, however, we recommend you download our Postman or Insomnia collection:
Click on the green label on the right to open the current schema structure and documentation for each field.
You can use the HTTP Headers section on the bottom to enter your credentials to be used with the queries:
{ "Authorization": "Bearer <your-token>" }
Depending on the call being made your bearer will either be a master token or a user token.
Our API docs indicate which token is required for each query / mutation.
IMPORTANT!: You will be interacting with live production data and any changes will be permanent.