I'm developing an API to integrate the Knack with Toggl. So, I need to post some data in the Toggl using an API that will be running in Google Script (JavaScript).
When I try to post somes projects in the Toggl, I receive the following error: "Request failed for https://www.toggl.com/api/v8/projects returned code 400. Truncated server response: Project can't be blank (use muteHttpExceptions option to examine full response) (line 61, file "")"
My source code is:
function sendDataToToggl(){
var apiToken = '936e292eaccd99b40358edea25452880';
var unamepass = apiToken + ":api_token";
var digest = Utilities.base64Encode(unamepass);
var digestfull = "Basic " + digest;
var url = "https://www.toggl.com/api/v8/projects";
var data = {"project":{"name":"An awesome project","wid":1034130,"template_id":1793088,"is_private":true,"cid":123397}};
var options = {
"Content-Type": "application/json",
"method": "post",
"headers": {"Authorization": digestfull},
"payload": data
//"muteHttpExceptions": true
};
var response = UrlFetchApp.fetch(url, options);
}