"token = os.getenv('SANDBOX_ZENODO_TOKEN_GARCIA') # Replace with your own token"
]
]
},
},
{
{
...
...
%% Cell type:markdown id:d5e9bc28 tags:
%% Cell type:markdown id:d5e9bc28 tags:
# Upload records on the OSSR
# Upload records on the OSSR
%% Cell type:markdown id:a4123841 tags:
%% Cell type:markdown id:a4123841 tags:
To upload records on the OSSR, you may use the [Zenodo client](https://gitlab.in2p3.fr/escape2020/wp3/eossr/-/blob/master/eossr/api/zenodo.py).
To upload records on the OSSR, you may use the [Zenodo client](https://gitlab.in2p3.fr/escape2020/wp3/eossr/-/blob/master/eossr/api/zenodo.py).
The client is also used by the continuous integration to automatise project's uploads from GitLab to Zenodo [check the EOSSR scripts here](https://gitlab.in2p3.fr/escape2020/wp3/eossr/-/tree/master/eossr/scripts).
The client is also used by the continuous integration to automatise project's uploads from GitLab to Zenodo [check the EOSSR scripts here](https://gitlab.in2p3.fr/escape2020/wp3/eossr/-/tree/master/eossr/scripts).
**However**, to upload records to the OSSR, you **will need** to use your Zenodo token ([create one](https://zenodo.org/account/settings/applications/tokens/new/)).
**However**, to upload records to the OSSR, you **will need** to use your Zenodo token ([create one](https://zenodo.org/account/settings/applications/tokens/new/)).
%% Cell type:code id:52aedbb2 tags:
%% Cell type:code id:52aedbb2 tags:
``` python
``` python
token=$SANDBOX_ZENODO_TOKEN_GARCIA
importos
token=os.getenv('SANDBOX_ZENODO_TOKEN_GARCIA')# Replace with your own token
```
```
%% Cell type:code id:6fcd7ef2 tags:
%% Cell type:code id:6fcd7ef2 tags:
``` python
``` python
importjson
importjson
fromeossr.api.zenodoimportZenodoAPI
fromeossr.api.zenodoimportZenodoAPI
# Please note that for this demo we are using Zenodo Sandbox.
# Please note that for this demo we are using Zenodo Sandbox.
z=ZenodoAPI(access_token=token,sandbox=True)
z=ZenodoAPI(access_token=token,sandbox=True)
```
```
%% Cell type:code id:24eecce0 tags:
%% Cell type:code id:24eecce0 tags:
``` python
``` python
```
```
%%Celltype:markdownid:c13a5232tags:
%%Celltype:markdownid:c13a5232tags:
## Create a new entry
## Create a new entry
Firstwewouldneedtocreateanewentry
Firstwewouldneedtocreateanewentry
%%Celltype:codeid:83075f0btags:
%%Celltype:codeid:83075f0btags:
``` python
``` python
new_entry = z.create_new_entry()
new_entry = z.create_new_entry()
```
```
%% Cell type:code id:84173c5d tags:
%% Cell type:code id:84173c5d tags:
``` python
``` python
```
```
%% Cell type:markdown id:fcd8e90c tags:
%% Cell type:markdown id:fcd8e90c tags:
### Zenodo API answer handler
### Zenodo API answer handler
We have also developped a REST API response client to manage the answers from the Zenodo API.
We have also developped a REST API response client to manage the answers from the Zenodo API.
%% Cell type:code id:22f8e2b2 tags:
%% Cell type:code id:22f8e2b2 tags:
``` python
``` python
from eossr.api.zenodo.http_status import ZenodoHTTPStatus
from eossr.api.zenodo.http_status import ZenodoHTTPStatus