Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagebash
titleCurl Example
curl 'https://wwwdemo.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"}'

...

Code Block
languagebash
titleJSON Result
{"sessionId":"HERE_WILL_BE_YOUR_SESSION_ID_THEN","sessionToken":"HERE_WILL_BE_YOUR_SESSION_TOKEN_THEN"}


Note

The examples can be tested with the commandline curl. In addition there are some online tools where you can directly paste the curl examples and test them too, for example https://reqbin.com/
Unfortunately the parameter --data-urlencode used in the examples is not usable in the online tools, so the data must be encoded first and send as raw data. So the line with --data-urlencode of the above example would change to:

--data-raw 'data=%7B%22login%22%3A%22manager%22%2C%22passwd%22%3A%22asdfasdf%22%7D'

List translation tasks (GET examples)

...

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

...

Code Block
languagebash
titleCurl Example
curl 'https://wwwdemo.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.

Filtering data

See Filtering, sorting and paging and other GET parameters.

Change Taskname (PUT example)

...

Code Block
languagebash
titleCurl Example
curl 'https://wwwdemo.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}'

...

Code Block
languagebash
titleCurl Example
curl 'https://wwwdemo.translate5.net/editor/task' -X POST  \
  -H 'Cookie: zfExtended=HERE_WILL_BE_YOUR_SESSION_ID_THEN' \
  -F "format=jsontext" \
  -F "taskName=This is a import test" \
  -F "sourceLang=de" \
  -F "targetLang=it" \
  -F "edit100PercentMatch=1" \
  -F "lockLocked=1" \
  -F "importUpload=@/PATH/TO/YOUR/FILE.xlf"

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

Since a import is running in the background, the so created task will be returned with a state = import. For checking if the import is done, a callback should be configured: task import push callback

Associate users to a task

...

Code Block
languagebash
titleCurl Example
curl 'https://wwwdemo.translate5.net/editor/taskuserassoc/' \
    -X POST -H 'Accept: application/json' \
    -H 'Cookie: zfExtended=HERE_WILL_BE_YOUR_SESSION_ID_THEN' \
    --data-urlencode 'data={"taskGuid":"TASKGUID","userGuid":"USERGUID","role":"translator","state":"open", "entityVersion":TASKVERSION}'

...

Code Block
languagebash
titleCurl Example
curl 'https://wwwdemo.translate5.net/editor/task/export/id/TASKID' -X GET -H 'Accept: application/json' -H 'Cookie: zfExtended=HERE_WILL_BE_YOUR_SESSION_ID_THEN' --output export.zip

...

Code Block
languagebash
titleCurl Example
curl 'https://wwwdemo.translate5.net/editor/task/TASKID' -X DELETE -H 'Cookie: zfExtended=HERE_WILL_BE_YOUR_SESSION_ID_THEN' \ 
    -H 'Accept: application/json' -H 'Mqi-Entity-Version: 123'

...

Calling the below request via POST will trigger the notifyAllUsers notification which sends an E-Mail to all associated proofreading usersassociated reviewers.

For the request the TASKID is needed, and the authenticated API user have at least the role "pm".

Code Block
curl 'https://wwwdemo.translate5.net/editor/task/TASKID/workflow' -X POST -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 'trigger=notifyAllUsersAboutTaskAssociation' --compressed

...