Add more complex requests example for API

This commit is contained in:
Carol Willing
2017-08-08 15:37:35 -07:00
parent f0556954ed
commit 4f95ef437f

View File

@@ -68,6 +68,26 @@ r.raise_for_status()
users = r.json() users = r.json()
``` ```
This example provides a slightly more complicated request, yet the
process is very similar:
```python
import requests
api_url = 'http://127.0.0.1:8081/hub/api'
data = {'name': 'mygroup', 'users': ['user1', 'user2']}
r = requests.post(api_url + '/groups/formgrade-data301/users',
headers={
'Authorization': 'token %s' % token,
},
json=data
)
r.raise_for_status()
r.json()
```
Note that the API token authorizes **JupyterHub** REST API requests. The same Note that the API token authorizes **JupyterHub** REST API requests. The same
token does **not** authorize access to the [Jupyter Notebook REST API][] token does **not** authorize access to the [Jupyter Notebook REST API][]
provided by notebook servers managed by JupyterHub. A different token is used provided by notebook servers managed by JupyterHub. A different token is used