Hi all,
Asana is giving me this error in my application:
"{"errors":[
{"message":"Request data must be a JSON object, not null","help":"For more information on API status codes and how to handle them, read the docs on errors: https://asana.com/developers/documentation/getting-started/errors"
}]
}"
The thing is, do I really need to send my data in JSON to API?
If i do it with curl in a terminal, it works fine:
curl -H "Authorization: Bearer 0/personal_token" https://app.asana.com/api/1.0/tasks --data-urlencode "assignee=blabla@blublu.com" --data-urlencode "notes=Hola mundo today?" --data-urlencode "name=Hello, world!" --data-urlencode "workspace=123456789"
As far as I know about my IDE (Qt creator and C++) this can be done using:
//Setting Header
request.setRawHeader(QByteArray("Authorization"), "Bearer 0/access_token");
//Codifing Header
request.setHeader(request.ContentTypeHeader,"Content-Type: application/x-www-form-urlencoded");
//Parameters of the request URL
postData.addQueryItem("assignee", "blablabla@blublublu.com");
postData.addQueryItem("notes", "Tarea de Prueba ASANA");
postData.addQueryItem("name", "PRIMERA TAREA");
postData.addQueryItem("workspace", "123456789");
Wich worked fine during my oauth process.
The thing is, I think I am wrong because “–data-urlencode” doesn’t join fields in a single URL and this curl (The one I perform in my IDE) doesent work:
curl -v -H "Authorization: Bearer 0/access_token" https://app.asana.com/api/1.0/tasks?assignee=dadada@bububu.com¬es=Tarea%20de%20Prueba%20ASANA&name=PRIMERA%20TAREA&workspace=123456
Which is the correct form of making a POST request (JSON or URL)?
Regards,
Daniel.