Available online at:
http://j.mp/ez-sc-2013-rest-api
GET
, POST
, PUT
, DELETE
, TRACE
OPTIONS
HEAD
PATCH
, COPY
, ...POST
, PUT
or custom verb requests/ezp/api/v1/
/ezp/api/v2/
ezpublish_rest:
pattern: ^/api/ezp/v2
stateless: true
ezpublish_http_basic:
realm: eZ Publish REST API
/user/sessions
201 Created
in case of successX-CSRF-Token
header required for non safe methodsPOST /api/ezp/v2/user/sessions HTTP/1.1
Host: ezpublish.ezsc
Content-Type: application/vnd.ez.api.SessionInput+json
Accept: application/vnd.ez.api.Session+json
{
"SessionInput": {
"login": "admin",
"password": "ezsc"
}
}
HTTP/1.1 201 Created
Date: Wed, 04 Sep 2013 08:29:57 GMT
Set-Cookie: eZSESSID=0ka4636cvs245lr6t6csgroto2; path=/
Status: 201 Created
Location: /api/ezp/v2/user/sessions/0ka4636cvs245lr6t6csgroto2
Set-Cookie: is_logged_in=true; path=/
Content-Type: application/vnd.ez.api.Session+json
{
"Session":{
"_media-type":"application\/vnd.ez.api.Session+json",
"_href":"\/api\/ezp\/v2\/user\/sessions\/0ka4636cvs245lr6t6csgroto2",
"name":"eZSESSID",
"identifier":"0ka4636cvs245lr6t6csgroto2",
"csrfToken":"c66dd36f4ced781c57b1e8407b16a507fb65272e",
"User":{
"_media-type":"application\/vnd.ez.api.User+json",
"_href":"\/api\/ezp\/v2\/user\/users\/14"
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<Root media-type="application/vnd.ez.api.Root+xml">
<content media-type="" href="/api/ezp/v2/content/objects"/>
<contentTypes media-type="application/vnd.ez.api.ContentTypeInfoList+xml" href="/api/ezp/v2/content/types"/>
<users media-type="application/vnd.ez.api.UserRefList+xml" href="/api/ezp/v2/user/users"/>
<roles media-type="application/vnd.ez.api.RoleList+xml" href="/api/ezp/v2/user/roles"/>
<rootLocation media-type="application/vnd.ez.api.Location+xml" href="/api/ezp/v2/content/locations//1/2"/>
<rootUserGroup media-type="application/vnd.ez.api.UserGroup+xml" href="/api/ezp/v2/user/groups//1/5"/>
<rootMediaFolder media-type="application/vnd.ez.api.Location+xml" href="/api/ezp/v2/content/locations//1/43"/>
<trash media-type="application/vnd.ez.api.Trash+xml" href="/api/ezp/v2/content/trash"/>
<sections media-type="application/vnd.ez.api.SectionList+xml" href="/api/ezp/v2/content/sections"/>
<views media-type="application/vnd.ez.api.RefList+xml" href="/api/ezp/v2/content/views"/>
</Root>
{
"Root": {
"_media-type": "application/vnd.ez.api.Root+json",
"roles": {"_href": "/api/ezp/v2/user/roles", "_media-type": "application/vnd.ez.api.RoleList+json"},
"content": {"_href": "/api/ezp/v2/content/objects", "_media-type": ""},
"users": {"_href": "/api/ezp/v2/user/users", "_media-type": "application/vnd.ez.api.UserRefList+json"},
"rootLocation": {"_href": "/api/ezp/v2/content/locations//1/2", "_media-type": "application/vnd.ez.api.Location+json"},
"contentTypes": {"_href": "/api/ezp/v2/content/types", "_media-type": "application/vnd.ez.api.ContentTypeInfoList+json"},
"views": {"_href": "/api/ezp/v2/content/views","_media-type": "application/vnd.ez.api.RefList+json"},
"trash": {"_href": "/api/ezp/v2/content/trash", "_media-type": "application/vnd.ez.api.Trash+json"},
"rootUserGroup": {"_href": "/api/ezp/v2/user/groups//1/5", "_media-type": "application/vnd.ez.api.UserGroup+json"},
"rootMediaFolder": {"_href": "/api/ezp/v2/content/locations//1/43", "_media-type": "application/vnd.ez.api.Location+json"},
"sections": {"_href": "/api/ezp/v2/content/sections", "_media-type": "application/vnd.ez.api.SectionList+json"}
}
}
Accept
headerapplication/vnd.ez.api.Content+xml
application/vnd.ez.api.Content+json
application/json
works too!Content-Type
headerapplication/vnd.ez.api.ContentCreate+json
application/vnd.ez.api.ContentCreate+xml
Command line with cURL
Base command:
curl -u "admin:ezsc" -i -H "Accept: application/json" http://ezpublish.ezsc/api/ezp/v2/
-i
to get response HTTP headers-u login:password
for HTTP Basic Auth-H "Http-Header: value"
to add a custom HTTP header-X VERB
to use a specific HTTP verb (GET is the default)-d @file.txt
to use the content of file.txt in the request bodyEzSystems/EzSummerCampRestApiBundle
/summercamp/rest-test
?