convert the interface numeric wrikeID to the API wrike ID

how to convert the numeric wrike id of a task to a wrike id for the api?

i do not want to crawl of search and program a whole framework just to get the wrike id

as i see it now i need to do a search and then fetch the id.. is there not a converting formula for the numeric id?

0
👍 Spot On 💡 Innovative Approach 💪 Stellar Advice ✅ Solved 🪄 Remove Kudos
1 comment

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++
}

}

}

1
👍 Spot On 💡 Innovative Approach 💪 Stellar Advice ✅ Solved 🪄 Remove Kudos

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

Top
Didn’t find what you were looking for? Write new post