api icon indicating copy to clipboard operation
api copied to clipboard

Patch request of completed task works on http request , but not update on app

Open RichardTwit opened this issue 6 years ago • 2 comments

I try to use the patch request to complete my task and I get a response for task completion, but it doesn't update on the wunderlist app. I did about 9 revision. I get a response that shows completion, but when I return to the app it shows no update. Here my response from the request:

{ "id": 3898040341, "created_at": "2018-06-01T10:20:00.703Z", "created_by_id": 24870738, "created_by_request_id": "worker:w:w:recurring_task_creator:parent-3858561041", "recurrence_type": "day", "recurrence_count": 1, "due_date": "2018-06-02", "completed": true, "completed_at": "2018-06-18T12:30:20.547Z", "completed_by_id": 24870738, "starred": false, "list_id": 350926181, "revision": 9, "title": "Turn on computer", "type": "task" }

It says I completed it today, but the apps didn't update on either my phone, tablet, or completed. Please help. Thanks.

RichardTwit avatar Jun 18 '18 13:06 RichardTwit

Hi @RichardTwit I am trying to update the title of my task. can you share your patch CURL command please. I am trying with API nodejs. using code below.

updateTaskProperties(data) {

        let updated_title = data.title + "#taskId:" + data.id + "";
        data.title = updated_title;

        console.log("updated_title data", data);

        var update_data = {
            'id': parseInt(data.id),
            'title': updated_title
        };

        return new Promise(function (resolve, reject) {

            wunderlistAPI.http.tasks.update(update_data)
                .done(function (updatedTask) {

                    console.log("updateTaskProperties response", updatedTask);
                    resolve(updatedTask);

                })
                .fail(function (err) {
                    console.error('updateTaskProperties error', err);
                    reject(err);
                });
        })
    }

its throwing an error.

updateTaskProperties error { errors: [ 'Error: Updating a resource requires an id of type number.' ] }

qadirsuh avatar Jun 20 '18 15:06 qadirsuh

Update:

I was doing wrong.

here is the code which worked for me like a charm :)

updateTaskProperties(data) {

        let original_title = data.title;
        let updated_title = original_title + "#taskId:" + data.id + "";
        data.title = updated_title;

        var update_data = {
            'title': updated_title
        };

        return new Promise(function (resolve, reject) {

            wunderlistAPI.http.tasks.update(data.id, data.revision, update_data)
                .done(function (updatedTask) {

                    console.log("updateTaskProperties response", updatedTask);
                    resolve(updatedTask);

                })
                .fail(function (err) {

                    console.error('updateTaskProperties error', err);
                    //reject(err);
                    data.title = original_title;
                    that.updateTaskProperties(data);
                    console.error('------Retrying update task title-------');
                });
        })
    }

qadirsuh avatar Jun 21 '18 14:06 qadirsuh