Using REST API via PHP to add custom_fields values to a task, I get 'Error: HTTP status code: 402'


#1

Hi,

I’ve been replicating the ‘Create Template’ function into my API so I create a project from scratch, I add the tasks that are in my template and the subtasks, I define the custom fields. All that is working well.

When I execute the request (PUT) to add custom fields values:

https://app.asana.com/api/1.0/tasks/" . $taskID,

I get this error: Error: HTTP status code: 402

Our workspace is premium and I tried with 2 different accounts token and I still get the same error. Why do I get this error? I remember that I managed to make it work some months ago in another application in the same workspace and the same account and it worked.

Thanks


#2

Error 402 is “Payment required” and in conjunction with custom fields, it usually means that you’re trying to add a custom field value in a project that’s in a non-Premium workspace or organization. Are you 100% sure your workspace is premium? Is there any chance the task is also associated with another project that’s non-Premium?


#3

Hi @Steven_Simard,

Sorry to hear you’re having this issue. Could you try making the PUT request to set custom fields via a CURL request? That will help isolate the issue.

Thanks,
Jeff


#4

How can I determine if a workspace or project is premium? I know the organization/workspace is premium since my company paid for it but I can’t find any way to check it out.

I’ve been doing the PUT request with a CURL request via PHP already.


#5

There’s no direct API call that gives you this information. You just have to attempt an API call that involves a premium feature and see if it fails with an error 402. Unfortunately that’s the situation that you’re already in!

You might try doing another unrelated premium API call into that workspace and see if that also produces a 402 error - if it does, that would confirm what you’re seeing with the custom fields. For example, you could try setting the Start Date on a task.


#6

Wow, I was trying to add the custom fields values before adding to the project… Now that I understand better the Asana structure, I see.

Thanks for helping, made me realize it!


#7

Ah, excellent, glad that’s cleared up!