Rest call from Embedded form

Hello,

I would like to make a Rest call to automaticly Claim the task to the user who click on it.

That my way:

camForm.on(‘form-loaded’, function() {

$scope.assignTask();

}

    inject(['Uri', '$http', function (Uri, $http) {
    $scope.assignTask = function () {
        return $http.post(Uri.appUri('engine://engine/:engine/task/' + camForm.taskId + '/claim'), {
            headers: {
                "Content-Type": "application/json;charset=utf-8"
            },
            body: {
                "userId": "demo"
            }
        });
    }
    }]);

I dont have Error but it’s not work…

I try the UnClaim and it’s works fine

inject(['Uri', '$http', function (Uri, $http) {
    $scope.unAssignTask = function () {
        console.log("task id = "+camForm.taskId );
        return $http.post(Uri.appUri('engine://engine/:engine/task/' + camForm.taskId + '/unclaim'), {});

    }
}]);

So what i do wrong ? Can i have any Help ??

Cordially,

Hey,

the second parameter contains just the request body. So instead of

you just write

 return $http.post(Uri.appUri('engine://engine/:engine/task/' + camForm.taskId + '/claim'), {
       "userId": "demo"
 });

Note that Tasklist will not immediately reflect the changed state.

@martin.stamm Thank you for your answer. It’s works very well.
I just have to reload the page to see the new assigne.

Happy new year and thank you again.