Page tree

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »


Using Browsers Development Tools

Best way to get examples is to use the browsers development tools to capture the browsers network communication while using translate5 through the frontend.

All below listed curl examples are generated via Google Chromes DevTools.

Authentication (POST example)

First of all we have to authenticate us at the translate5 installation.The authentication is session based.

To authenticate we POST the data parameter containing the JSON data to the /editor/session URL.

More information about the session API.

Curl Example
curl 'https://www.translate5.net/editor/session' -X POST -H 'Accept: application/json' \
     -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
     --data-urlencode 'data={"login":"manager","passwd":"asdfasdf"}'

On success this results in a similar JSON as the following. All further calls need the returned sessionId then.

JSON Result
{"sessionId":"HERE_WILL_BE_YOUR_SESSION_ID_THEN","sessionToken":"HERE_WILL_BE_YOUR_SESSION_TOKEN_THEN"}

List translation tasks (GET examples)

As next step we can list all tasks available in translate5.

More information about the task API.

Curl Example
curl 'https://www.translate5.net/editor/task?start=0&limit=20' -X GET -H 'Accept: application/json' -H 'Cookie: zfExtended=HERE_WILL_BE_YOUR_SESSION_ID_THEN'

On success this results in a JSON containing the first (start=0) 20 (limit=20) tasks in translate5.

To get a single task you need the task id (from the above returned JSON), then you can access the single task (replace TASKID accordingly):

Curl Example
curl 'https://www.translate5.net/editor/task/TASKID' -X GET -H 'Accept: application/json' -H 'Cookie: zfExtended=HERE_WILL_BE_YOUR_SESSION_ID_THEN'

On success this results in a JSON containing the requested task.

Change Taskname (PUT example)

We change the taskname just to demonstrate a PUT request to change a data entity on the server.

More information about the task API.

To update the taskname the TASKID is needed again, also the entityVersion of the task. The entityVersion is contained in the previously fetched task entity. It is needed to prevent that two different users change an entity at the same time.

Curl Example
curl 'https://www.translate5.net/editor/task/TASKID' -X PUT -H 'Cookie: zfExtended=HERE_WILL_BE_YOUR_SESSION_ID_THEN' \ 
     -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json' \
     --data-urlencode 'data={"taskName":"New Task Name","entityVersion":123}'

On success this results in a JSON containing the changed task.

Import Task (POST example with fileupload)

Due historical reasons coming from the used frontend framework, POST requests containing file uploads are different as the above shown POSTs without files.

A POST with fileupload contains the entities attrbutes not as JSON, but as plain form fields.

Curl Example
curl 'https://www.translate5.net/editor/task/TASKID' -X PUT -H 'Cookie: zfExtended=HERE_WILL_BE_YOUR_SESSION_ID_THEN' \ 
     -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json' \
     --data-urlencode 'data={"taskName":"New Task Name","entityVersion":123}'



  • No labels