2015-07-12 92 views
2

從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" 

回答

0

我不知道PowerShell腳本語法可言,所以我不會有任何幫助那裏。

但是,如果projects參數正常工作,而其他人不是,因爲他們都在相同的語法,我會感到驚訝。我看到你有assignee= @{"id"=$assignee}

請注意,API預期的語法是assignee=1235。你可以看到一個example in curl on our documentation

相關問題