toggl / toggl_api_docs

Documentation for the Toggl API
1.4k stars 235 forks source link

Update time entry wid and pid to different. #330

Closed LiamKarlMitchell closed 2 years ago

LiamKarlMitchell commented 5 years ago

I'm wanting to move time entries from a workspace and project to a different workspace and project.

Getting this error response. "Conflict with project/workspace: project needs to be in the same workspace as the time entry\n"

update goes like this. { wid: newWorkSpaceID, pid: newProjectID }

Is this broken, maybe the PID same workspace check needs check if there is a new wid set.

I can do it with two updates if I first update pid to null, then update the wid and pid.

x-yuri commented 3 years ago

@LiamKarlMitchell By two updates you meant this?

{wid: 123, pid: null}
{wid: 123, pid: 456}

It doesn't seem to work anymore. Any follow-up?

LiamKarlMitchell commented 3 years ago
            //  - Conflict with project/workspace: project needs to be in the same workspace as the time entry
            // See: https://github.com/toggl/toggl_api_docs/issues/330
            // Unset current PID.
            if (timeEntry.pid) {
              let result = await toggl.updateTimeEntryAsync(timeEntry.id, { pid: null })
            }

            // Set new WID and PID.
            let result2 = await toggl.updateTimeEntryAsync(timeEntry.id, { wid: config.Toggl.workspaceId, pid: newProjectId })

Yeah something like that was what I did back then at least but WID would be different. Wanted to move a time entry from one workspace and project to a different workspace and project.

Actually probably easier to just create a new one and delete the old.

x-yuri commented 3 years ago

Yeah something like that was what I did back then at least but WID would be different.

Oh, indeed. That's what I meant.

And I just tried it separately:

$ curl -sS -u $api_token:api_token -X PUT -H "Content-Type: application/json" \
-d '{"time_entry": {"pid": null}}' \
https://api.track.toggl.com/api/v8/time_entries/$teid

$ curl -sS -u $api_token:api_token -X PUT -H "Content-Type: application/json" \
-d '{"time_entry": {"wid": $wid, "pid": $pid}}' \
https://api.track.toggl.com/api/v8/time_entries/$teid

And it worked. I apparently made some mistake when doing it in a script.

joeriharleman commented 2 years ago

Hello @LiamKarlMitchell!

Thank you for submitting your issue. Unfortunately this repository is largely unmaintained, which means issues remain unseen and do not get dealt with in a respectable manner. We're sorry for not getting back to you sooner.

This issue has been around for a long time so we will close it for now, but please let our excellent 24/5 support staff know you if you have any unresolved issues with our platform, documentation or APIs. They're also really good at noting down feature requests for our development teams. Please find them on our support page by clicking the little icon in the bottom right corner of the screen.

Kind regards, Joeri from Toggl