Background: JavaScript (V8) code being controlled by C# via ClearScript. It’s a project called Lychen.
This is the code creating the JSON packet:
// ct - create task - ct/project/assignee/name/notes
var Console = CS.System.Console;
var DateTime = CS.System.DateTime;
var File = CS.System.IO.File;
var Path = CS.System.IO.Path;
if (ARGUMENTS.length < 5) {
Console.WriteLine("{0} needs four parameters (/project/assignee/name/notes)", ARGUMENTS[0]);
} else {
REQUEST = new RESTSHARP.RestRequest("api/1.0/tasks", RESTSHARP.Method.POST);
var token = ASANA_SETTINGS.IniReadValue("Authorisation", "Token", "");
if (token === "") {
Console.WriteLine("Token not found in AsanaSettings.INI");
} else {
REQUEST.AddHeader("Authorization", "Bearer " + token);
REQUEST.AddHeader("Content-Type", "application/json");
var json = JSON.stringify({
projects: [{ gid: ARGUMENTS[1] }],
assignee: { gid: ARGUMENTS[2] },
name: ARGUMENTS[3],
notes: ARGUMENTS[4],
workspace: { gid: WORKSPACE }
});
REQUEST.AddJsonBody(json);
RESPONSE = CLIENT.Execute(REQUEST);
var tag = DateTime.Now.ToString("yyyy'-'MM'-'dd'-'HH'-'mm");
File.WriteAllText(Path.Combine("log", "ct_" + tag + ".json"), RESPONSE.Content);
}
}
This is the packet of JSON:
{"projects":[{"gid":"1113266773900829"}],"assignee":{"gid":"9814050857874"},"name":"Task 1","notes":"Added we assume to Test Project","workspace":{"gid":"9814050864025"}}
And this is the error message:
{"errors":[{"message":"You should specify one of workspace, parent, projects","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"}]}
What I don’t get is that there is a projects and a workspace. And it’s not a subtask so I don’t need a parent (and I have tried putting a null parent in to no effect.)
Where’s the problem?