POST request with std.net.curl

bachmeier no at spam.net
Fri Jul 23 18:11:51 UTC 2021


I'm writing a D program that interacts with the Todoist API using 
std.net.curl. It's not a problem to do get requests to query 
tasks, but I cannot find a way to get post to work to create a 
new task.

This is a working bash script, where APIKEY is defined elsewhere 
and $1 and $2 are user input when running the script:

```
curl "https://api.todoist.com/rest/v1/tasks" -X POST --data 
"{"'"'"content"'"'": "'"'"$1"'"'", "'"'"project_id"'"'": $2}" -H 
"Content-Type: application/json" -H "Authorization: Bearer 
$APIKEY"
```

(For obvious reasons I'm not going to provide a working example.) 
How can I translate this into a post function call within D?

[Todoist API 
Reference](https://developer.todoist.com/rest/v1/?shell#create-a-new-task)


More information about the Digitalmars-d-learn mailing list