How to use Google Apps Script to create issues in Redmine? -


i'm trying create issue in redmine using google apps script, code following:

function create_issue() {   var payload = {     'project_id': 'helpdesk',     'subject': 'this test ticket',     'description': 'this genius test ticket',     'category_id': 1   };   var headers = {     'x-redmine-api-key': '<myapikey>',     'content-type': 'application/json'   };   var url = 'http://myredmine.com/issues.json';   var options = {     'method': 'post',     'headers': headers,     'payload': payload,     //utehttpexceptions': true   };   var response = urlfetchapp.fetch(url, options);   logger.log(response); } 

every time ran script, threw following exception:

execution failed: request failed http://myredmine.com/issues.json returned code 422. truncated server response: {"errors":["subject can't blank"]} (use mutehttpexceptions option examine full response) (line 25, file "code") [0.645 seconds total runtime]

but see, "subject" parameter passed in payload already. missing?

thanks,

trinh

i found problem, need indicate issue in payload:

function create_issue() {   var issue = {     "description": "test ticket",      "subject": "genius ticket"   }   var payload = {     "issue": issue,      "key": "<myapikey>",      "project_id": "helpdesk",   };   payload = json.stringify(payload);   var headers = {     'x-redmine-api-key': '<myapikey>',     'content-type': 'application/json'   };   var url = 'http://myredmine.com/issues.json';   var options = {     'method': 'post',     'headers': headers,     'payload': payload,     'contenttype': 'application/json',     //'mutehttpexceptions': true   };   var response = urlfetchapp.fetch(url, options);   logger.log(response); } 

and works!


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -