After a little help in regards to posting a new message to the Basecamp API using Google Script.
I have created a function, pasted below but when running this through the debugger I get a 422 response from Basecamp saying the <title>
attribute is empty which it isn't
<?xml version="1.0" encoding="UTF-8"?> <errors> <error>Title can't be blank</error> </errors>
I have tried the same POST via the 'Advanced Rest Client' in Chrome and the post is successful.
function postBasecampApi(endpoint, payload) {
var xml = ""+
'<request>'+
'<post>'+
'<category-id>123890662</category-id>'+
'<title>sting</title>'+
'<body>testing</body>'+
'</post>'+
'<notify>test notify</notify>'+
'</request>';
var url = basecampCompleteUrl + '/projects/12029591/posts.xml';
var headers = {
Authorization : 'Basic ' + Utilities.base64Encode(user + ':' + password)
}
var opt = {
'method': 'POST',
'payload': xml,
'headers' : headers
};
var response = UrlFetchApp.fetch(url, opt);
return Xml.parse(response.getContentText(), false);
}
Thanks in advance for any help