Tuesday, 16 April 2019

Complete a Task Step in SDL WorldServer using the REST API

In this article, I would like to present a method for completing an active Task Step in SDL WorldServer using the REST API.

The method takes three parameters:
  1. wsBaseUrl
  2. token
  3. completeTaskStepRequestBody
The wsBaseUrl must be the <serverURL>:<portnumber> where your WorldServer instance is running.

The second parameter is a security token, which can be retrieved by using the SDL WorldServer REST API as explained here.

The third parameter is a CompleteTaskStepRequestBody object containing the data to support the task step completion. This includes the id (task id), the transitionId and an optional comment to set as metadata. The task id and transition id can be retrieved by invoking the REST call described here for retrieving the tasks from a specified Project. The returned TaskDetails object provides the data.

The method returns a boolean value specifying whether the task step completion was successful.

Download an asset associated with a TASK in SDL WorldServer using the REST API

In this article, I would like to present a method for downloading a file (asset) associated with a Task in SDL WorldServer using the REST API.

The method takes six parameters:
  1. wsBaseUrl
  2. token
  3. taskId
  4. assetName
  5. downloadLocation
  6. assetLocationType
The wsBaseUrl must be the <serverURL>:<portnumber> where your WorldServer instance is running.

The second parameter is a security token, which can be retrieved by using the SDL WorldServer REST API as explained here.

The third parameter is the id of the Task in SDL WorldServer to download the asset from.

The fourth parameter is the name of the asset to download. This can be retrieved by invoking the REST call described here for retrieving the tasks from a specified Project. The returned TaskDetails object provides the targetAsset attribute containing the path to the target asset. Use this path to work out the file (asset) name.

The firth parameter is the path to the download location where to place the downloaded file.

Finally the sixth parameter is used to determine the location type: SOURCE, TARGET or SOURCE_TARGET.

The method returns a String containing the path to the downloaded file.

Get a list of Tasks from a Project in SDL WorldServer using the REST API

In this article, I would like to present a method for retrieving a list of Tasks from a Project in SDL WorldServer using the REST API.

The method takes three parameters:
  1. wsBaseUrl
  2. token
  3. projectId
The wsBaseUrl must be the <serverURL>:<portnumber> where your WorldServer instance is running.

The second parameter is a security token, which can be retrieved by using the SDL WorldServer REST API as explained here.

The third parameter is the id of the Project in SDL WorldServer to retrieve the tasks from.

The method returns a List of TaskDetails objects, one for each task returned, containing a subset of the JSON response data.

Create Project Groups in SDL WorldServer using the REST API

In this article, I would like to present a method for creating a Project Group in SDL WorldServer using the REST API.

The method takes three parameters:
  1. wsBaseUrl
  2. token
  3. projectGroups
The wsBaseUrl must be the <serverURL>:<portnumber> where your WorldServer instance is running.

The second parameter is a security token, which can be retrieved by using the SDL WorldServer REST API as explained here.

The third parameter is a List of ProjectGroup objects, each one containing the data required for creating each Project Group in WorldServer. This includes the namedescriptionprojectTypeIdclientId, the list of files for translation (systemFiles) and the list of Locales (target locales). The systemFiles attribute (List of String) must be populated with each asset's internalName returned by the file upload process described here.

The method returns a List of CreateProjectGroupResponse objects, one for each project group created, containing the JSON response data. With this data, it is possible to verify if the call was successful and also retrieve the newly created project group id.

Upload files to SDL WorldServer using the REST API

In this article, I would like to present a method for uploading a collection of files to SDL WorldServer using the REST API.

The method takes three parameters:
  1. wsBaseUrl
  2. token
  3. files
The wsBaseUrl must be the <serverURL>:<portnumber> where your WorldServer instance is running.

The second parameter is a security token, which can be retrieved by using the SDL WorldServer REST API as explained here.

The third parameter is a Collection of File objects for upload.

The method returns a List of FileUploadResponse objects, one for each uploaded file, containing data from the uploaded asset. With this information, it is possible to create Projects in WorldServer using the REST API and place these assets through translation.

Retrieve the list of active Projects available in SDL WorldServer using the REST API

In this article, I would like to present a method for retrieving the list of active Projects in SDL WorldServer using the REST API.

The method takes two parameters:
  1. wsBaseUrl
  2. token
The wsBaseUrl must be the <serverURL>:<portnumber> where your WorldServer instance is running.

The second parameter is a security token, which can be retrieved by using the SDL WorldServer REST API as explained here.

The method returns a List of Project objects, one for each active project, containing a subset of the JSON response data.

Connecting to SDL WorldServer using the REST API

It is now possible to connect to SDL WorldServer and perform a number of actions by using the WorldServer REST API. The REST API documentation is available from your WorldServer instance by accessing <serverURL>:<portnumber>/ws-api/docs/ws-api-doc-v1.html.

In this article I present a method for connecting to SDL WorldServer and fetching a security token to be used in all subsequent API calls.

The method takes three parameters:
  1. wsBaseUrl
  2. username
  3. password
The wsBaseUrl must be the <serverURL>:<portnumber> where your WorldServer instance is running. The login method will append the "/ws-api/v1/login" path required for invoking the REST based login call.

As mentioned earlier, the call returns a security token to be used in all subsequent API calls.