Create and Update API Source Entries

Portrait allows you to configure a source with sourceType: 'api'. These sources can be manually managed through the API.

Create the source in the config

First, you need to create a source in the Configuration. Details API sources

The source name must be in lowercase (wrong: EM2008, correct; em2008)

Example:

- id: em2008 sourceType: 'api' excludeKeysFromSuggestions: [ ]

Manage Entries

The most up-to-date API Specification can always be found on your own instance, either via the openAPI specification or the UI! See API Documentation

Create a new entry

To create an entry, use the following request:

POST /api/sources/:sourceName

curl -X 'POST' \ 'http://localhost:8080/api/sources/em2008' \ -H 'accept: application/json' \ -H 'Authorization: Bearer yourToken' \ -H 'Content-Type: application/json' \ -d '{ "id": "GERESP", "name": "EM 2008 - Final", "data": { "key": "GERESP", "Opponents": "Germany - Spain", "KickOff": "2008-06-29T20:45:00", "Result": "0:1", "Venue": "Ernst-Happel-Stadion, Vienna", "Weather": "Sunny, 27 °C (81 °F), 4% humidity", "Referee": "Roberto Rosetti (ITA)", "Latitude": "48.207208", "Longitude" : "16.420985" } }'

The id attribute has to be unique.

Update an existing entry

PUT /api/sources/:sourceName

curl -X 'PUT' \ 'http://localhost:8080/api/sources/em2008' \ -H 'accept: application/json' \ -H 'Authorization: Bearer yourToken' \ -H 'Content-Type: application/json' \ -d '{ "id": "GERESP", "name": "EM 2008 - Final", "data": { "key": "GERESP", "Opponents": "Germany - Spain", "KickOff": "2008-06-29T20:45:00", "Result": "0:1", "Venue": "Ernst-Happel-Stadion, Vienna", "Weather": "Sunny, 27 °C (81 °F), 4% humidity", "Referee": "Roberto Rosetti (ITA)", "Latitude": "48.207208", "Longitude" : "16.420985" } }'

Remove an existing entry

DELETE /api/sources/:sourceName/:entryID

Remove all entries from an API source

PATCH /api/sources/:sourceName

 

Copyright Treskon GmbH.