Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Completes a Task Step in SDL WorldServer using the REST API
public class CompleteTaskStepRequestBody {
private int id;
private int transitionId;
private String comment;
public int getId() {
return id;
public void setId(int id) { = id;
public int getTransitionId() {
return transitionId;
public void setTransitionId(int transitionId) {
this.transitionId = transitionId;
public String getComment() {
return comment;
public void setComment(String comment) {
this.comment = comment;
public static boolean completeTaskStep(String wsBaseUrl, String token, CompleteTaskStepRequestBody completeTaskStepRequestBody)
throws IOException, URISyntaxException {
JsonObject jsonObject = doPost(wsBaseUrl, "/ws-api/v1/tasks/complete", token, Arrays.asList(completeTaskStepRequestBody));
return StringUtils.equals(jsonObject.getAsJsonPrimitive("status").getAsString(), "OK");
public static JsonObject doPost(String wsBaseUrl, String restPath, String token, Object pojo)
throws IOException, URISyntaxException {
URI postUri = new URIBuilder(wsBaseUrl + restPath)
.addParameter("token", token)
.addParameter("content-type", "application/json")
HttpClient httpClient = HttpClientBuilder.create().build();
HttpPost httpPost = new HttpPost(postUri);
HttpResponse response = httpClient.execute(httpPost);
Gson gson = new GsonBuilder().create();
return gson.fromJson(new InputStreamReader(response.getEntity().getContent()), JsonObject.class);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment