Skip to content

Commit

Permalink
IQSS#6083 update examples in File part of Native API: 'Getting File M…
Browse files Browse the repository at this point in the history
…etadata' section.
  • Loading branch information
pkiraly committed Feb 17, 2020
1 parent be6678b commit b6494b7
Showing 1 changed file with 64 additions and 4 deletions.
68 changes: 64 additions & 4 deletions doc/sphinx-guides/source/api/native-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1782,13 +1782,73 @@ Example::
Getting File Metadata
~~~~~~~~~~~~~~~~~~~~~
Provides a json representation of the file metadata for an existing file where ``id`` is the database id of the file to replace or ``pid`` is the persistent id (DOI or Handle) of the file::
Provides a json representation of the file metadata for an existing file where ``ID`` is the database id of the file to replace or ``PERSISTENT_ID`` is the persistent id (DOI or Handle) of the file
GET http://$SERVER/api/files/{id}/metadata
A curl example using an ``ID``
The current draft can also be viewed if you have permissions and pass your ``apiKey``::
.. code-block:: bash
export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
export SERVER_URL=https://demo.dataverse.org
export ID=24
curl $SERVER_URL/api/files/$ID/metadata
The fully expanded example above (without environment variables) looks like this:
.. code-block:: bash
curl https://demo.dataverse.org/api/files/24/metadata
A curl example using a ``PERSISTENT_ID``
.. code-block:: bash
export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
export SERVER_URL=https://demo.dataverse.org
export PERSISTENT_ID=doi:10.5072/FK2/AAA000
curl "$SERVER_URL/api/files/:persistentId/metadata?persistentId=$PERSISTENT_ID"
The fully expanded example above (without environment variables) looks like this:
.. code-block:: bash
curl "https://demo.dataverse.org/api/files/:persistentId/metadata?persistentId=doi:10.5072/FK2/AAA000"
The current draft can also be viewed if you have permissions and pass your API token
A curl example using an ``ID``
.. code-block:: bash
export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
export SERVER_URL=https://demo.dataverse.org
export ID=24
curl -H "X-Dataverse-key:$API_TOKEN" $SERVER_URL/api/files/$ID/metadata/draft
The fully expanded example above (without environment variables) looks like this:
.. code-block:: bash
curl -H "X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" https://demo.dataverse.org/api/files/24/metadata/draft
A curl example using a ``PERSISTENT_ID``
.. code-block:: bash
export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
export SERVER_URL=https://demo.dataverse.org
export PERSISTENT_ID=doi:10.5072/FK2/AAA000
curl -H "X-Dataverse-key:$API_TOKEN" "$SERVER_URL/api/files/:persistentId/metadata/draft?persistentId=$PERSISTENT_ID"
The fully expanded example above (without environment variables) looks like this:
.. code-block:: bash
GET http://$SERVER/api/files/{id}/metadata/draft?key={apiKey}
curl -H "X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" "https://demo.dataverse.org/api/files/:persistentId/metadata/draft?persistentId=doi:10.5072/FK2/AAA000"
Note: The ``id`` returned in the json response is the id of the file metadata version.
Expand Down

0 comments on commit b6494b7

Please sign in to comment.