Asana Salesforce integration using API - Giving Bad Request Error

Hello Team,

I have tried making an API call with below sample request but its giving Bad Request(Error code:400).

Please find the below API Request and Response details. I have used Oauth authentication with salesforce named credentials as a connection setup.

End Point URL : https://app.asana.com/api/1.0/tasks, Method=POST

API Request:

JSON format: {“data”:{“start_on”:null,“resource_subtype”:“default_task”,“projects”:[“1201175728978789”],“parent”:null,“notes”:“test Asana SF”,“name”:“test”,“liked”:true,“ex”:null,“due_on”:null,“due_at”:null,“completed_by”:null,“completed”:false,“assignee_section”:null,“assignee”:null}}

System.HttpResponse[Status=Bad Request, StatusCode=400]

DEBUG|{“errors”:[{“message”:“Could not interpret {"data":{"start_on":null,"resource_subtype":"default_task","projects":["1201175728978789"],"parent":null,"notes":"test Asana SF","name":"test ","liked":true,"ex":null,"due_on":null,"due_at":null,"completed_by":null,"completed":false,"assignee_section":null,"assignee":null}} as an identifier in {"data":{"start_on":null,"resource_subtype":"default_task","projects":["1201175728978789"],"parent":null,"notes":"test Asana SF","name":"test","liked":true,"ex":null,"due_on":null,"due_at":null,"completed_by":null,"completed":false,"assignee_section":null,"assignee":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"}]}

Please share your experience and knowledge to help mitigate the above issue.

Thanks,
Priyanka

Hi,

I am not sure you need to wrap everything inside a data attribute… can you try removing it?

API requests do typically need the data wrapper.

One thing you should do is remove all of the fields in which you’re passing null or the default value. You don’t need to supply any field where you’re not sending valid data, and in fact Asana recommends against sending those. That will eliminate probably 95% of the body of your request.

(Also note that ex is not a valid field name.)

Let us know the outcome after stripping down the request (and post the updated request if it’s still not working).

Thanks, I use the nodeJS wrapper too often and forgot the data wrapper was indeed expected.

Hello Thanks for your reply.

As you suggested, I modified the request to remove the null fields and try to submit but still its giving me same error:

API Request: : JSON format: {“data”:{“resource_subtype”:“default_task”,“projects”:[“1201175728978789”],“notes”:“test Asana SF”,“name”:“test”}}

Response:
System.HttpResponse[Status=Bad Request, StatusCode=400]

{“errors”:[{“message”:“Could not interpret {"data":{"resource_subtype":"default_task","projects":["1201175728978789"],"notes":"test Asana SF","name":"test"}} as an identifier in {"data":{"resource_subtype":"default_task","projects":["1201175728978789"],"notes":"test Asana SF","name":"test"}}.”,“help”:“For more information on API status codes and how to handle them, read the docs on errors: Build an app with Asana”}]}

Thanks,
Priyanka

@Priyanka_Gajula,

There should be a text error message that gets returned along with the 400, which should give you some additional clue as to the issue. I recommend running the request in Postman or equivalent; that will give you the clear error response.

Hello Phil,

As you suggested I tried running my request in Postman, it successfully ran and task has been created in Asana.

But from salesforce when I am sending the same request its failing. So is there problem of authentication method. I created APP under ‘Asana Developer App Console’ and mapped it with my salesforce org.

Can you please suggest what would be the issue.

Thanks,
Priyanka

Unfortunately I don’t have any experience with integrating Salesforce to the Asana API so I won’t be of any help there. Anyone else have said experience?