Community

Welcome 🖖

Hi there! 🙂 Want to become a black belt Wrike Ninja? Here's how to earn a Wrike badge

Welcome 🖖 Have you checked out this week's Release Notes yet?

Hey! 👋 Curious about something? Visit How To to search and ask the Community for answers.

Welcome! 👋 Figured out a good tip or trick? Share it in Best Practices.

Want to connect your existing software to Wrike? Learn and ask how in the API section.

Чем мы можем помочь?

Примеры запросов: диаграмма Ганта, оплата в рублях, предоставление доступа к папкам...

convert the interface numeric wrikeID to the API wrike ID

1 комментарий

  • Spot On! 👍 Innovative Approach 💡 Stellar Advice 💪
    Avatar
    Jan Dijk

    (Изменен )

    i found the solution with the permalink field.

    snippit to resolve the task id by the old permalink id in powershell

    ---
    $v2wrikeid = xxxxxxx
    $wriketaskData = Invoke-RestMethod -uri https://www.wrike.com/api/v4/tasks?permalink=https://www.wrike.com/open.htm?id=$v2wrikeid -Headers @{'Authorization' = ' bearer '+$accessToken} -Method get
    $wrikeID=$wriketaskData.data.GetValue(0).id
    echo $wrikeID
    ---

     

    here i share some quick and dirty code to add an time entry to a task for a whole year every workday in powershell

    ----

    #create wrike time entries for every workday for a whole year
    # uncomment the $output line to actually do it, first test the print out

    $accessToken = "yourv4token"
    # the permalinkid
    $v2wrikeid = XXXXXX
    $beginmonth=1
    $beginyear=2019

    $wriketaskData = Invoke-RestMethod -uri https://www.wrike.com/api/v4/tasks?permalink=https://www.wrike.com/open.htm?id=$v2wrikeid -Headers @{'Authorization' = ' bearer '+$accessToken} -Method get
    $wrikeID=$wriketaskData.data.GetValue(0).id

    #Print week


    $we = [System.DayOfWeek]::Saturday, [System.DayOfWeek]::Sunday

    $date = Get-Date -Year $beginyear -Month $beginmonth -Day 1

    for ($i=$beginmonth; $i -le 12; $i++)
    {

    $date = Get-Date -Year $beginyear -Month $i -Day 1

    $lastDay = [DateTime]::DaysInMonth($date.Year, $date.Month)
    $firstDate = [DateTime]::new($date.Year, $date.Month, 1)
    $lastDate = [DateTime]::new($date.Year, $date.Month, $lastDay)

    $workdays = 0
    #$now=$firstDate.AddDays(-1)
    $now=$firstDate

    while ($now -le $lastDate){

    $now = $now.AddDays(1)

    if ($now.DayOfWeek -notin $we ) {

    $payload = 'hours=0.5&trackedDate=' + ($now).Tostring("yyyy-MM-dd") + '&comment=' + ($now).Tostring("yyyy-MM-dd") + ': time entry subject |'
    #uncomment to actually output, test it manually first before you loop.
    ##$output = Invoke-RestMethod -uri https://www.wrike.com/api/v4/tasks/$wrikeID/timelogs -Headers @{'Authorization' = ' bearer '+$accessToken} -Method Post -body $payload
    $payload
    Remove-Variable payload

    $workdays++
    }

    }

    }

    Is this helpful? 1
    Действия с комментариями Постоянная ссылка

Войдите в службу, чтобы оставить комментарий.

Folllowing List for Post: convert the interface numeric wrikeID to the API wrike ID
[this list is visible for admins and agents only]

Community

Welcome 🖖

Hi there! 🙂 Want to become a black belt Wrike Ninja? Here's how to earn a Wrike badge

Welcome 🖖 Have you checked out this week's Release Notes yet?

Hey! 👋 Curious about something? Visit How To to search and ask the Community for answers.

Welcome! 👋 Figured out a good tip or trick? Share it in Best Practices.

Want to connect your existing software to Wrike? Learn and ask how in the API section.