Search code examples
curlpostapplescript

How do I run a curl script with a POST request in applescript?


I have a curl POST request in cli that looks like this:

curl -H "Authorization: Bearer TOKEN" \
 https://app.asana.com/api/1.0/tasks \
 --data-urlencode "assignee=IDNUMBER" \
 --data-urlencode "notes=TASKNOTE" \
 --data-urlencode "name=TASKNAME" \
 --data-urlencode "workspace=WORKSPACEID" \
 --data-urlencode "project=PROJECTID" 

This POST works fine, and returns what I need.

However I want to have a similar script ran in applescript, via the 'do shell script' command. How would it look?


Solution

  • Actually it's the same syntax replacing the double quotes with single quotes and removing the backslash line separators

    do shell script "curl -H 'Authorization: Bearer TOKEN' https://app.asana.com/api/1.0/tasks --data-urlencode 'assignee=IDNUMBER' --data-urlencode 'notes=TASKNOTE' --data-urlencode 'name=TASKNAME' --data-urlencode 'workspace=WORKSPACEID' --data-urlencode 'project=PROJECTID'"