Send data from Zoho CRM to Teamwork Project
Hello everyone,
I created a function that is supposed to set up a milestone in Teamwork Project (from teamwork.com) but I can't make it work. I don't get any response code so I'm kinda stuck here, can anyone tell me what I've been doing wrong ?
Here is the
Teamwork doc, and the
milestone reference. I noticed that Teamwork expect the POST request to be made with HTTPS, but the postURL doc from Zoho doesn't say anything about that, can it be an issue ?
Thanks in advance
Oh and here is the code :
- createTeamworkTask (string Quote_ID, string Auth, string Project_ID ) {
- quoteID=input.Quote_ID.toLong();
- //Get the data to be send
- quoteData = zoho.crm.getRecordById("Quotes",quoteID);
- quoteTitle=quoteData.get("Subject");
- quoteText=quoteData.get("Description");
- quoteDate=(quoteData.get("Valid Till")).toString();
- deadline=quoteDate.replaceAll("-","");
- //Prepare the data with mandatory fields filled up
- teamworkData=map();
- teamworkData.put("title",quoteTitle);
- teamworkData.put("description",ifnull(quoteText,""));
- teamworkData.put("responsible-party-ids","118535");
- teamworkData.put("deadline",deadline);
- teamworkDataLayer="[" + teamworkData + "]";
- //Set the prepared data in valid JSON and format it the way Teamwork expect it to be
- data=map();
- data.put("milestone",teamworkDataLayer);
- dataJSONString=data.toString().replaceAll("]\"","]");
- dataJSONString=dataJSONString.replaceAll("\"\[","\[");
- dataValidJSON=dataJSONString.replaceAll("\\\"","\"");
- //Set header info, auth key is provided by a CRM variable
- headerData=map();
- headerData.put("Authorization",input.Auth);
- headerData.put("Content-type","application/json");
- header="[" + headerData + "]";
- //The URL is composed with the project ID, provided by a CRM variable
- url="https://urgh.teamwork.com/projects/" + input.Project_ID + "/milestones.json";
- teamwork = postUrl(url,dataValidJSON,header,false);
- info teamwork;
- //Check if data has been send successfully and display a message according to situation
- code=teamwork.get("responseCode");
- response=teamwork.get("responseText");
- if(code != "200")
- {
- message=((((("Une erreur est survenue, contactez un administrateur.") + "\n") + "Erreur ") + code) + " : ") + response;
- }
- else
- {
- message="Jalon créé dans Teamwork";
- }
- return message;
- }