Creating a New Task and Assigning to Project via AppleScript

Hi Everyone,

I’m trying to get the following script to work, and while I can get the task to be added, I can’t seem to get it to assign the task to an existing project, no matter what I try (array, memberships, project, projects, etc.)

I’ve included the latest working version and was wondering if someone could point me in the right direction? Right now it simply adds the task without attaching to the project.

Thanks
John

on run {input, parameters}

set prompt to “Please name the task:”

set dialogResult to display dialog prompt ¬

buttons {“Cancel”, “OK”} default button 2 ¬

default answer “test”

–default answer input

set theTaskTitle to text returned of dialogResult

set theProjectName to “123456789”

set url_text to "curl -X “POST” “https://app.asana.com/api/1.0/tasks” -H "Authorization: Bearer TOKEN\” -H ‘Content-Type: application/x-www-form-urlencoded; charset=utf-8’ --data-urlencode "workspace=WORKSPACE\” --data-urlencode "assignee=ASSIGNEE\” --data-urlencode “name=”

set url_text to url_text & theTaskTitle & “”"

set url_text to url_text & " --data-urlencode “project=” & theProjectName & “”"

set response to do shell script url_text

end run

If you look at https://developers.asana.com/docs/create-a-task it should be projects with an array of IDs…