After getting the planning (Get projects from Teamweek in jQuery) successfully via the API i now want to create feed teamweek a project.
The following code works (according to the response i get) but i can't find the project when i log in to teamweek.
create_project = function(_project)
{
console.log('Sending new project to teamweek', _project);
return $.ajax(
{
url : api_url + app.model.teamweek_account_id + '/projects/new.json',
type : 'POST',
dataType : 'jsonp',
cache : false,
data : {
"active" : true,
"client_id" : _project.client,
"color" : "#f00",
"name" : _project.title,
"id" : _project.project_number
},
beforeSend: function (request) { return request; },
success:function(response) {
return response;
},
error: function (jqXHR, textStatus, errorThrown) {
console.error('error getting teamweek planning:', jqXHR, textStatus, errorThrown);
},
});
},
Response:
{
"project": {
"name": "text",
"client_id": "integer",
"color": "string",
"active": "boolean"
},
"links": [{
"href": "https://teamweek.com/api/v2/:my_account_id/projects",
"rel": "create",
"method": "POST"
}, {
"href": "https://teamweek.com/api/v2/:my_account_id/projects/:id",
"rel": "update",
"method": "PUT"
}, {
"href": "https://teamweek.com/api/v2/:my_account_id/projects/:id",
"rel": "read",
"method": "GET"
}, {
"href": "https://teamweek.com/api/v2/:my_account_id/projects/:id",
"rel": "delete",
"method": "DELETE"
}, {
"href": "https://teamweek.com/api/v2/:my_account_id/projects",
"rel": "list",
"method": "GET"
}]
})