Our updated docs do not include examples for users, so here are a few for users who are struggling to get the REST API to work for them.
If you haven't already seen our REST API docs, you can find them here: https://docs.dominodatalab.com/en/latest/api_guide/8c929e/rest-api-reference/
When reviewing the REST API docs, please make sure to select the version of Domino that matches your deployment, as shown below:
Example 1: Current User Info
Our fist example we'll do a simple query that returns the users information - this query can be found in the docs here. Please note that we are using Python 3. To test this out please copy and past the below query into a python file titled userAPItest.py:
import urllib.request
import json
headers = {
'X-Domino-Api-Key': '<add your Domino API key here'
}
request = urllib.request.Request('<add your deployment url here>/v4/users/self', headers=headers)
response_body = urllib.request.urlopen(request).read()
print (response_body)
Next, add your API key and deployment url as indicated in the code snippet.
Then, run in your terminal using this command:
python3 userAPItest.py
You may need to install some packages on your machine to get it to work for you.
Example 2: Add a user to an organization
In the this example, we'll add a user to an organization as noted in the docs here. This is a little trickier as you'll need to collect the organization ID, the user ID who you want to add and your Domino deployment url.
Once you've collected the information, please add it to the query below:
curl -X PUT "https://<base_url>/api/organizations/v1/organizations/<organization id>/user" -H "Content-Type: application/json" -H 'X-Domino-Api-Key:<API KEY>' -d '{"userId": "<user id>", "organizationRole": "Member"}'
Finally, run it from the terminal on your local machine.
Comments
0 comments
Please sign in to leave a comment.