通过powershell将数据添加到asana
问题描述:
从Asana获取数据似乎工作正常,当我通过Invoke-RestMethod
添加数据时,它允许我创建任务,但名称,备注字段和受理人未被填充。有任何想法吗?通过powershell将数据添加到asana
例如:
function Add-asanaTask {
param([string]$apikey, [string]$taskName, [string]$notes, [string]$assignee, [string]$workspaceid,[string]$projectid, $url = 'https://app.asana.com/api/1.0/workspaces/{0}/tasks')
$apikey = "{0}:" -f $apikey
$url = $url -f $workspaceID
$url
$Mykey = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($apikey))
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization","Basic $Mykey")
$task [email protected]{
[email protected]{
assignee= @{"id"=$assignee};
name=$taskname;
notes=$notes;
[email protected]{"id"=$projectid}
}
}#end task object
$json = $task | ConvertTo-Json
$response = Invoke-RestMethod $url -Method Post -Body $json -Headers $headers
return $Response.data
}
add-asanatask -apikey "apikey" -taskName "test task" -notes "hello world" -assignee "assignee ID" -workspaceid "workspace ID" -projectid "project ID"
答
我不知道PowerShell脚本语法可言,所以我不会有任何帮助那里。
但是,如果projects
参数正常工作,而其他人不是,因为他们都在相同的语法,我会感到惊讶。我看到你有assignee= @{"id"=$assignee}
。
请注意,API预期的语法是assignee=1235
。你可以看到一个example in curl on our documentation。