Testing REST API¶
A standard web browser isn't sufficient to fully test the API.
You can, however, try opening the root resource with it, using the session authentication: http://example.com/api/ibexa/v2/
.
Depending on how your browser understands XML, it either downloads the XML file, or opens it in the browser.
The following examples show how to interrogate the REST API with cURL, PHP or JS.
To test further, you can use browser extensions, like Advanced REST client for Chrome or RESTClient for Firefox, or dedicated tools. For command line users, HTTPie is a good tool.
CLI¶
For examples of using curl
, refer to:
PHP¶
You can use Symfony HttpClient to test REST API.
Open a PHP shell in a terminal with php -a
1 2 3 4 5 6 7 |
|
$resource
URI should be edited to address the right domain.
On a freshly installed Ibexa DXP, 52
is the Content ID of the home page.
If necessary, substitute 52
with the content ID of an item from your database.
For a content creation example that uses PHP, see Creating content with binary attachments
JS¶
The REST API can help you implement JavaScript / AJAX interaction.
The following example of an AJAX call retrieves ContentInfo
(that is, metadata) for a content item.
To test it, copy-paste this code into your browser console alongside a page from your website (to share the domain):
1 2 3 4 5 6 7 8 9 10 |
|
1 2 3 4 5 6 7 8 9 |
|
On a freshly installed Ibexa DXP, 52
is the Content ID of the home page.
If necessary, substitute 52
with the Content ID of an item from your database.
You can edit the resource
URI to address another domain, but cross-origin requests must be allowed first.