Hi, I am fairly new to using the API. I am using PHP… Trying out how the API functions before propperly implementing it.
For what we want to achieve we have to duplicate tasks, I am strugling with the documentation, it tells me that the function excists but does not provide a proper example for the include field.
What is expected to be passed in (what type/ in what form)?
And may I ask why it is not the same accros the entire api…
This does not work, I have played around… passing multiple values in… Like how [‘headers’ => [‘asana-disable’ => ‘disabled_fields’]] works… But this does not work either, I keep getting ‘Invalid request’
Could someone provide me with a proper code example in PHP on how to use this include field?
It is frustating this is not globally the same, since passing in the values like I did above does in fact work for creating and updating tasks (Why not for duplicating it?)
In the documentation does not tell me how the field works… I have provided it an array with the field include… containing a string value(in docs it says it expects a string for the field)
and name is a string (same as in the example). Just in the docs they use php and thus have to do array(param => field) I can simply do [param => field]… This is identical
Original request here, in the examples I will just show the include array
//Does not work (invalid request, just like everything I try)
public function duplicate($project, $task)
{
AsanaController::getClient()->tasks->duplicateTask($task, ['include' => 'name']);
return redirect()->back();
}
[
'include' => ['projects', 'name'],
]
-------------------
array('include' => array('projects', 'name'))
//These two should be equal anyway ^
//Pass as one long string
[
'include' => 'projects, name, notes, resource_subtype, completed',
]
//Pass as long string inside another array
[
'include' => ['projects, name, notes, resource_subtype, completed'],
]
Every single one returns ‘Invalid request’. To eliminate it is the way I process this I have rewritten it so it would update the task to completed in the exact same function (just temp replaced it)
public function duplicate($project, $task)
{
AsanaController::getClient()->tasks->updateTask($task, ['completed' => true]);
return redirect()->back();
}
This works fine. But i just want to duplicate it…
I see you post alot here Phil. Happen to know someone that does know PHP that might be able to help me. Just one code example would be enough…
I have been testing this my self and found out there are 2 required parameters one in includes, which is ‘projects’ and then name or it wont work as the below example works.
Apologies as I was testing this out during my reply and did not see you found the solution your self. But as stated ‘projects’ parameter in includes and the name parameter that is required other than that you can use any other parameters you require