Functions described in this document are invoked by passing requests to this URL:
{base url}/ws/{function_name}/api/{api_version}?method=copyThe request must be json.
// generate the URL. Can also be https $url = "http://de.piksel.tech/ws/{function_name}/api/{api_version}"?method=copy; *Use method get param only if the client does not support COPY method to submit data. (some flash clients). Use COPY http header to send request data. // base 64 encode the request: $request = "{json request}" // Capture response with CURL $handle = curl_init(); curl_setopt( $handle, CURLOPT_URL, $url ); curl_setopt( $handle, CURLOPT_POSTFIELDS, array("request" => $request) ); curl_setopt( $handle, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec( $handle ); curl_close( $handle );
The body tag of the request JSON is <request></request>, containing 3 main sections:
<authentication> | User authentication data used to authorize request |
<header> | Header section specifies the API version to be used when calling a given function |
<{API Function}> | Specifies which function to call and contains relevant parameters |
Contains the following fields
<user_token> | Contains the user token string value, returned by the login function successful response. Should be saved for subsequent requests within the session |
<client_token> | <client_token> Client UUID which can be found by navigating to Client Preferences -> API Consumer Accounts |
<app_name> | The web application name that calls the web services. |
<app_token> | API token constant string value |
<no_cache> | Boolean value to specify whether authentication will done freshly or from cache. |
An example of the authentication section
{ "request": { "header": { "header_version": 1, "api_version": "4", "no_cache": true }, "login": { "username": "", "password": "", "static_login": false } } }
Contains the following fields
<header_version> | Not used for the moment – empty value |
<api_version> | The API version number to be used – numeric value |
An example of header section:
"header": { "header_version": 1, "api_version": "4", "no_cache": true }
<{API function name}> | The API function name to call. This tag has no attributes and contains different child tags (or does not contain any), depending on the API function called, ie. It's content is function specific and described in detail for each function in the Post API Function Docs. |
Following is an example COPY request document for calling the function ws_vod_project :
"ws_vod_project": { "title": "PROJECT TITLE", "description": "DESCRIPTION", "tag": "TAG", "referenceId": "abc123", "copyProject": { "uuid": "zyx987" } }
Here is a complete example using all of three of the previously discussed sections.
{ "request": { "authentication": { "app_token": "7cd207c2-6808-11e3-b865-22000a8a28ea", "client_token": "d4c1b92c0acb102ba3e10015c5f061d1", "user_token": "f277cb9d46e45f67f44de949cdde110f" }, "header": { "header_version": 1, "api_version": "5", "no_cache": true }, "ws_vod_project": { "title": "PROJECT TITLE", "description": "DESCRIPTION", "tag": "TAG", "referenceId": "abc123", "copyProject": { "uuid": "zyx987" } } } }
The response data returned by Piksel Digital Enterprise API v5.0 is also JSON with base node named <response> and contains a {function_name}_response tag for the called function. It contains a status section and different child tags, depending on the API function called. The status section can contain either success or failure tags:
Tag returned in case of successful execution of an API function. It has no attributes and contains the following child tags:
<code> | Status code returned by the API function, integer value |
<message> | Some specific message set from the function, string value |
<details> | Additional details, if available, also function specific |
<dtstamp> | Date/time stamp in format YYYY-MM-DD HH:MM:SS, string value |
An example of successful tag:
"success": { "code": 533, "message": "Vod Project Copied", "details": "" }
Tag returned in failure case from the API function called. It contains no attributes and the following child tags
<code> | Status code returned by the API function, integer value |
<reason> | Some specific message set from the function, reason for the failure, string value |
<details> | Additional details, if available, also function specific |
<severity> | Severity of the function failure, string value |
<dtstamp> | Date/time stamp in format YYYY-MM-DD HH:MM:SS, string value |
An example of a failure tag:
"failure": { "code": 102, "reason": "Invalid app token.", "details": "", "severity": "Error", "dtstamp": "2014-04-14 14:20:44" }
Example of full failure response document returned by login API function:
{ "response": { "failure": { "code": 102, "reason": "Invalid app token.", "details": "", "severity": "Error", "dtstamp": "2014-04-14 14:20:44" } } }
And now a complete successful response document from the same function:
{ "response": { "success": { "code": 533, "message": "Vod Project Copied", "details": "" } } }