cURL Examples
From DreamFactory
(→cURL Examples) |
|||
Line 1: | Line 1: | ||
==Login as an admin - POST to /system/admin/session== | ==Login as an admin - POST to /system/admin/session== | ||
− | * Use returned session_token as X-DreamFactory-Session-Token header in subsequent API calls. | + | * Use returned session_token as '''X-DreamFactory-Session-Token''' header in subsequent API calls. |
<pre> | <pre> | ||
Line 11: | Line 11: | ||
==Login as a user - POST to /user/session== | ==Login as a user - POST to /user/session== | ||
− | * Use returned session_token as X-DreamFactory-Session-Token header in subsequent API calls. | + | * Use returned session_token as '''X-DreamFactory-Session-Token''' header in subsequent API calls. |
<pre> | <pre> |
Revision as of 13:26, 18 May 2018
Contents
- 1 Login as an admin - POST to /system/admin/session
- 2 Login as a user - POST to /user/session
- 3 Get all records from table named todo.
- 4 Create a new todo record.
- 5 Update todo record with id = 1.
- 6 Delete todo record with id = 1.
- 7 Logout as an admin - DELETE /system/admin/session
- 8 Logout as a user - DELETE /user/session
Login as an admin - POST to /system/admin/session
- Use returned session_token as X-DreamFactory-Session-Token header in subsequent API calls.
curl -i -k -3 -X POST "http://localhost:8080/api/v2/system/admin/session" \ -d '{ "email" : "user@example.com", "password" : "pass123" }' \ -H "Content-Type: application/json"
Login as a user - POST to /user/session
- Use returned session_token as X-DreamFactory-Session-Token header in subsequent API calls.
curl -i -k -3 -X POST "http://localhost:8080/api/v2/user/session" \ -d '{ "email" : "user@example.com", "password" : "pass123" }' \ -H "Content-Type: application/json"
Get all records from table named todo.
curl -i -k -3 -X GET "http://localhost:8080/api/v2/db/_table/todo" \ -H "X-DreamFactory-Api-Key: <api key for app in the apps tab>" \ -H "X-DreamFactory-Session-Token: <session token from login response>"
Create a new todo record.
curl -i -k -3 -X POST "http://localhost:8080/api/v2/db/_table/todo" \ -H "X-DreamFactory-Api-Key: <api key for app in the apps tab>" \ -H "X-DreamFactory-Session-Token: <session token from login response>" \ -H "Content-Type: application/json" \ -d '{"resource":[{ "name" : "curl todo", "complete" : false }]}'
Update todo record with id = 1.
curl -i -k -3 -X PATCH "http://localhost:8080/api/v2/db/_table/todo/1" \ -H "X-DreamFactory-Api-Key: <api key for app in the apps tab>" \ -H "X-DreamFactory-Session-Token: <session token from login response>" \ -H "Content-Type: application/json" \ -d '{ "complete" : true }'
Delete todo record with id = 1.
curl -i -k -3 -X DELETE "http://localhost:8080/api/v2/db/_table/todo/1" \ -H "X-DreamFactory-Api-Key: <api key for app in the apps tab>" \ -H "X-DreamFactory-Session-Token: <session token from login response>"
Logout as an admin - DELETE /system/admin/session
curl -i -k -3 -X DELETE "http://localhost:8080/api/v2/system/admin/session" \ -H "X-DreamFactory-Session-Token: <session token from login response>"
Logout as a user - DELETE /user/session
curl -i -k -3 -X DELETE "http://localhost:8080/api/v2/user/session" \ -H "X-DreamFactory-Session-Token: <session token from login response>"