API Endpoint
http:islab1.ieis.tue.nl:8024/api
Authentication
An access token is necessary to be used in each request.
Summary of resources
/user
/player
/challenge
/gameDescriptor
/property
/propertyType
/propertyInstance
/gameSession
/tag
/dataProvider
/tokenForDataProvider
/rointMapping
/role
/support
/circle
/personalPoint
/participation
/reward
/sponsor
/rightToShowChallenge
/challengeRule
/condition
/operator
To perform an operation on any of the above listed resources, you just need to append the resource as it is, with the API endpoint. Of course it varies from request to request, so for example in case of GET and DELETE you just append the resource to the endpoint but for POST or PUT you need to specify the parameters and their values accordingly. For details, see the relevant sections for those methods.
Request pattern
curl -X $Method -H “Authorization: Bearer $token” http://islab1.ieis.tue.nl:8024/api/player
In this request, the variable with $ sign needs to be replaced by its values. For example, in the example request below we have replaced $Method with GET and $token with the value of the access token.
Example request
curl -X GET -H “Authorization: Bearer 797d8861-1436-4bd5-97c2-2e7bd9884749” http://islab1.ieis.tue.nl:8024/api/player
Sample response for the same request above, but when executed from a REST client.
Get a Token via Login service
Get the OAUTH token
curl -X POST -H “Content-Type: application/x-www-form-urlencoded” -d “grant_type=password” -d “username=testuser@example.com” -d “password=testpass” http://$gamebus:secret@localhost:8989/oauth/token | jq -r ‘.access_token’
connection refused
curl -X GET -H “Content-Type: application/x-www-form-urlencoded” -d “grant_type=password” -d “username=testuser@example.com” -d “password=testpass” http://gamebus:secret@localhost:8989/oauth/token | jq -r ‘.access_token’
connection refused
Get token (out of script) returns null
curl -X POST -H “Content-Type: application/x-www-form-urlencoded” -d “grant_type=password” -d “username=testuser@example.com” -d “password=testpass” http://gamebus:@localhost:8989/oauth/token | jq -r ‘.access_token’
Failed to connect to localhost port 8989: connection refused
curl -X GET -H “Content-Type: application/x-www-form-urlencoded” -d “grant_type=password” -d “username=testuser@example.com” -d “password=testpass” http://gamebus:@localhost:8989/oauth/token | jq -r ‘.access_token’
Failed to connect to localhost port 8989: connection refused
curl curl:testpass@localhost:8989/oauth/token\?grant_type=client_credentials
curl curl:testpass@localhost:8989/oauth/token\?grant_type=password
Insert a GameDescriptor
curl -H “Authorization: Bearer 108cf321-06c1-4d30-bb2c-d7904b87cc6e” -X POST -H “Content-Type: application/json” -d “{\”name\”: \”Memory\”, \”tag\”: \”cognitive\”}” http://localhost:8989/api/gameDescriptor
#Retrieve all the gameDescriptors
curl -X GET -H “Authorization: Bearer 108cf321-06c1-4d30-bb2c-d7904b87cc6e” http://localhost:8989/api/gameDescriptor
#Based on Id of a (chosen) gameDescriptor, post a new GameSession
curl -H “Authorization: Bearer 108cf321-06c1-4d30-bb2c-d7904b87cc6e” -X POST -H “Content-Type: application/json” -d “{\”createdAt\”: \”07-07-2015\”, \”isManual\”: \”true\”}” http://localhost:8989/api/gameDescriptor/1/gameSession
Retrieving resources:
curl -X GET -H “Authorization: Bearer 108cf321-06c1-4d30-bb2c-d7904b87cc6e” http://localhost:8989/api/player
curl -X GET -H “Authorization: Bearer 108cf321-06c1-4d30-bb2c-d7904b87cc6e” http://localhost:8989/api/user
curl -X GET -H “Authorization: Bearer 108cf321-06c1-4d30-bb2c-d7904b87cc6e” http://localhost:8989/api/gameDescriptor
#Get a specific player with id (or entity likewise)
curl -X GET -H “Authorization: Bearer 108cf321-06c1-4d30-bb2c-d7904b87cc6e” http://localhost:8989/api/player/2
#Get circles for a player with id
curl -X GET -H “Authorization: Bearer 108cf321-06c1-4d30-bb2c-d7904b87cc6e ” http://localhost:8989/api/player/2/circles
curl -X GET -H “Authorization: Bearer 108cf321-06c1-4d30-bb2c-d7904b87cc6e” http://localhost:8989/api/player/2/supports
curl -X GET -H “Authorization: Bearer 108cf321-06c1-4d30-bb2c-d7904b87cc6e” http://localhost:8989/api/player/2/gameSessions
curl -X GET -H “Authorization: Bearer 108cf321-06c1-4d30-bb2c-d7904b87cc6e” http://localhost:8989/api/player/2/tokensForDataProvider
Creation of resources
Create a user
curl -H “Authorization: Bearer 108cf321-06c1-4d30-bb2c-d7904b87cc6e” -X POST -H “Content-Type: application/json” -d “{\”firstName\”: \”Carolina\”, \”lastName\”: \”Gomez\”, \”email\”: \”c.gomez@tue.nl\”, \”password\”: \”testpassword\”}” http://localhost:8989/api/user
curl -H “Authorization: Bearer 108cf321-06c1-4d30-bb2c-d7904b87cc6e” -X POST -H “Content-Type: application/json” -d “{\”age\”: \”25\”, \”sex\”: \”male\”, \”height\”: \”5\”, \”weight\”: \”80\”, \”gameDescriptor\”: \”valueForGameDescriptor\”, \”circle\”: http://localhost:8080/circle/1\, \”gameSession\” : \”http://localhost:8080/gameSession/1\”}” http://localhost:8989/player
POST a PropertyInstance with a reference to Property
curl -H “Authorization: Bearer 108cf321-06c1-4d30-bb2c-d7904b87cc6e” -X POST -H “Content-Type: application/json” -d “{\”value\”: \”51\”, \”property\”: \”http://localhost:8989/api/property/5\”}” http://localhost:8989/api/propertyInstance
Add the value 51 for property score (which is property 5) in propertyInstance
Check (test after the execution)
curl -X GET -H “Authorization: Bearer 108cf321-06c1-4d30-bb2c-d7904b87cc6e” http://localhost:8989/api/property/5/propertyInstances
Add another value to 32, to see if it really works (regression test)
curl -H “Authorization: Bearer 108cf321-06c1-4d30-bb2c-d7904b87cc6e” -X POST -H “Content-Type: application/json” -d “{\”value\”: \”32\”, \”property\”: \”http://localhost:8989/api/property/5\”}” http://localhost:8989/api/propertyInstance
curl -X GET -H “Authorization: Bearer 108cf321-06c1-4d30-bb2c-d7904b87cc6e” http://localhost:8989/api/property/5/propertyInstances
This time it shows both previous values, 51, 51 and newly added (32)
We have to try update to see, if the old value gets updated or not?
Some other checks
curl -X GET -H “Authorization: Bearer 108cf321-06c1-4d30-bb2c-d7904b87cc6e” http://localhost:8989/api/propertyInstance/19/property (for value 32)
This returns “Score” as a property.
Update a value
curl -H “Authorization: Bearer 108cf321-06c1-4d30-bb2c-d7904b87cc6e” -X PUT -H “Content-Type: application/json” -d “{\”value\”: \”53\”, \”property\”: \”http://localhost:8989/api/property/5\”}” http://localhost:8989/api/propertyInstance/17
Updates PropertyInstance (17)’s value from 51 to 53.
Verify: Issue this request
curl -X GET -H “Authorization: Bearer 108cf321-06c1-4d30-bb2c-d7904b87cc6e” http://localhost:8989/api/property/5/propertyInstances
It returns all 3 property Instances with values as 51, 32, and 53 which were earlier 51,32, and 51.
Delete a value
- First I’m creating a new PropertyInstance, then I’ll delete it, just to keep the older ones as they are.
- curl -H “Authorization: Bearer 108cf321-06c1-4d30-bb2c-d7904b87cc6e” -X POST -H “Content-Type: application/json” -d “{\”value\”: \”49\”, \”property\”: \”http://localhost:8989/api/property/5\”}” http://localhost:8989/api/propertyInstance
curl -H “Authorization: Bearer 108cf321-06c1-4d30-bb2c-d7904b87cc6e” -X POST -H “Content-Type: application/json” -d “{\”value\”: \”13\”, \”property\”: \”http://localhost:8989/api/property/5\”}” http://localhost:8989/api/propertyInstance
- Check if it is added
curl -X GET -H “Authorization: Bearer 108cf321-06c1-4d30-bb2c-d7904b87cc6e” http://localhost:8989/api/property/5/propertyInstances
yes it got added, new reference is 20
- Delete it
curl -H “Authorization: Bearer 108cf321-06c1-4d30-bb2c-d7904b87cc6e” -X DELETE -H “Content-Type: application/json” -d “{\”property\”: \”http://localhost:8989/api/property/5\”}” http://localhost:8989/api/propertyInstance/20
The above is correct way to delete
curl -H “Authorization: Bearer 108cf321-06c1-4d30-bb2c-d7904b87cc6e” -X DELETE -H “Content-Type: application/json” -d http://localhost:8989/api/propertyInstance/21
This results in error: curl, no url specified
- Check if it got deleted or not
curl -X GET -H “Authorization: Bearer 108cf321-06c1-4d30-bb2c-d7904b87cc6e” http://localhost:8989/api/property/5/propertyInstances
It is deleted.
Updates and Changes
See the history for details
History
Friday, Aug 07, 2015. Summary of resources, an example request.
Monday, Aug 10, 2015. Insert a GameDescriptor
Monday, Aug 10, 2015.
Curl requests to get token directly failing. Currently it is achieved through running a script.
Creation of resources
Retrieving resources
Updating resources
Deleting resources
Regression Tests
