Overview
These examples are for a Fedora hands-on workshop and are referenced by these slides. All examples are displayed below in a curl command-line form. For those who do not have curl or prefer a graphical interface, the examples can be obtained as a JSON import file for the POSTMan REST client.
Linked Data Platform
Create the Pythagoras collection
POST http://localhost:8080/rest/
CURL Command:
curl -X POST -H "Slug: pythagoras" -H "Content-Type: text/turtle" -H "Accept: text/turtle" --data-binary "@request-body.ttl" http://localhost:8080/rest/
request-body.ttl
@prefix dc: <http://purl.org/dc/terms/> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . <> dc:title 'Pythagoras Collection'; dc:abstract 'A collection of materials and facts about Pythagoras' .
Add Pythagoras the Person
POST http://localhost:8080/rest/pythagoras/
CURL Command:
curl -X POST -H "Slug: person" -H "Link: <http://www.w3.org/ns/ldp#Resource>; rel="type"" -H "Content-Type: text/turtle" --data-binary "@request-body.ttl" http://localhost:8080/rest/pythagoras/
request-body.ttl
@prefix dc: <http://purl.org/dc/terms/> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . <> a foaf:Person; foaf:name 'Pythagoras' ; foaf:based_near "Croton" ; foaf:interest [ dc:title "Geometry" ] .
Get Pythagoras collection
GET http://localhost:8080/rest/pythagoras
CURL Command:
curl -X GET -H "Accept: text/turtle" http://localhost:8080/rest/pythagoras
POST Portrait Container
POST http://localhost:8080/rest/pythagoras
CURL Command:
curl -X POST -H "Content-Type: text/turtle" -H "Slug: portraits" --data-binary "@request-body.ttl" http://localhost:8080/rest/pythagoras
request-body.ttl
@prefix ldp: <http://www.w3.org/ns/ldp#> . @prefix dcterms: <http://purl.org/dc/terms/> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . <> a ldp:DirectContainer; ldp:membershipResource </rest/pythagoras/person>; ldp:hasMemberRelation foaf:depiction; dcterms:title "Portraits of Pythagoras" .
POST a Portrait
POST http://localhost:8080/rest/pythagoras/portraits
CURL Command:
curl -X POST -H "link: <http://www.w3.org/ns/ldp#Resource>; rel="type"" -H "Content-Type: image/jpeg" http://localhost:8080/rest/pythagoras/portraits
GET Portrait Container
GET http://localhost:8080/rest/pythagoras/portraits
CURL Command:
curl -X GET -H "Accept: text/turtle" http://localhost:8080/rest/pythagoras/portraits
GET Pythagoras Person
GET http://localhost:8080/rest/pythagoras/person
CURL Command:
curl -X GET -H "Accept: text/turtle" http://localhost:8080/rest/pythagoras/person
POST List of Pythagoras' Influences
POST http://localhost:8080/rest/pythagoras/
CURL Command:
curl -X POST -H "Content-Type: text/turtle" -H "Slug: influences" --data-binary "@request-body.ttl" http://localhost:8080/rest/pythagoras/
request-body.ttl
@prefix ldp: <http://www.w3.org/ns/ldp#> . @prefix dcterms: <http://purl.org/dc/terms/> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix ph: <http://example.org/vocab/philosophy#> . <> a ldp:IndirectContainer; ldp:membershipResource <http://localhost:8080/rest/pythagoras/person>; ldp:hasMemberRelation foaf:knows; ldp:insertedContentRelation foaf:primaryTopic; dcterms:title "List of People that Influenced Pythagoras" .
Add Thales as Influence
POST http://localhost:8080/rest/pythagoras/influences/
CURL Command:
curl -X POST -H "Slug: thales" -H "Content-Type: text/turtle" --data-binary "@request-body.ttl" http://localhost:8080/rest/pythagoras/influences/
request-body.ttl
@prefix dcterms: <http://purl.org/dc/terms/> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . <> dcterms:title "Thales"; foaf:primaryTopic <http://en.wikipedia.org/wiki/Thales> .
GET List of Influences
GET http://localhost:8080/rest/pythagoras/influences
CURL Command:
curl -X GET -H "Accept: text/turtle" --data-binary "@request-body.ttl" http://localhost:8080/rest/pythagoras/influences
request-body.ttl