Hey all,
I’m trying to create a task via Asana’s awesome API.
What I did:
I’m making a POST request to https://app.asana.com/api/1.0/tasks
With the following POST variables
projects=1234
workspace=5678
due_on=2018-04-21
name=testone
notes=blah
assignee=9876543210
collaborators[0]=123456789
What I expected:
The task is created
What happens:
I get a 400 error message
Response:{“errors”:[{“message”:“Could not interpret \n as an identifier in \n.”,“help”:“For more information on API status codes and how to handle them, read the docs on errors: Build an app with Asana”}]}
Has anyone else encountered this? I can’t see anywhere in my request that I’ve included a newline character or a literal “\n”
Maybe one of the asana devs could tell me what I’m doing wrong.
Thanks so much fam,
Andrew
To simplify the problem can you try to remove due_on, notes, assignee and collaborators?
Hey Bastien!
Thanks!
Sorted, it’s working!
I tried grabbing the whole request using netcat, so we could take a peek at what’s going on.
Here’s the request that causes the bug.
sudo nc -l 80
POST /tasks HTTP/1.1
Authorization: Bearer [redacted]
Cache-Control: no-cache
Pragma: no-cache
User-Agent: Java/1.8.0_151
Host: localhost
Accept: text/html, image/gif, image/jpeg, *; q=.2, /; q=.2
Connection: keep-alive
Content-type: application/x-www-form-urlencoded
Content-Length: 61
projects=1234&workspace=5678&name=testone&
Note the sneaky newline in there.
I eventually fixed this; my Java code was inserting a newline character because I was using:
outWriter.printLn( buff.toString() );
instead of outWriter.print( buff.toString() );
when I was writing the GET URL.
Thanks!
Andrew
Awesome you got it sorted it!
1 Like
Hey @Andrew_QPay,
Happy to hear you got this figured out. I wanted to mention that you should never share your Personal Access Token. It’s essentially a password to your Asana account. I edited your post to remove it.
Cheers!
Jeff
2 Likes
Thanks Jeff! Must have missed it when pasting, it was on a test asana workspace anyway, so no harm done, but good to follow good policy! Of course I’ve rolled the token in any case.
Also cheers Bastien!
Thanks for your help all!
Andrew