Need to send Attachement via REST message along with other data to Azure Devops

Bhuvanesh Babu
Giga Expert

Hi All and @Ankur Bawiskar , 

I have refered and gone through many posts in community but was not successful, 

Requirement is I have a BR that creates a ticket in Azure Devops if a checkbox is enabled, this works fine but I also need to send attachments (be it any type / multiple attachments) if it is present in that particular Incident. 

Please let me know if its possible and how to achive this.

Note: Below is the code snippet (replaced data/fields with 'x')

Regards,

Babu

var hasattachments = current.hasAttachments();
gs.addErrorMessage(hasattachments);
	

    var incUrl = gs.getProperty('glide.servlet.uri') + 'incident.do?sys_id=' + current.sys_id;

    if (plmGroup)
        incDesc += 'Group: ' + plmGroup + '<br/>';
    if (plmRole)
        incDesc += 'Role: ' + plmRole + '<br/>';
    incDesc += current.description + '<br/>' + '<div><a href=' + '\'' + incUrl + '\'' + '>Link to ServiceNow</a> Incident</div>';

    try {
        var r = new sn_ws.RESTMessageV2('xxx', 'POST');
        if (current.assignment_group == 'xxxxxxxxxxx') { 
        
        r.setStringParameterNoEscape('x', incShortDesc.replaceAll('"', "'"));
        r.setStringParameterNoEscape('x', reqEmail);
        r.setStringParameterNoEscape('x', incNumber);
        r.setStringParameterNoEscape('x', incPriority);
        r.setStringParameterNoEscape('x', path);
        r.setStringParameterNoEscape('x', 'bug');

		if (hasattachments == true){


		}
        var response = r.execute();
        var responseBody = response.getBody();
        var httpStatus = response.getStatusCode();
        var subject = "Integration " + httpStatus;
        if (httpStatus != "200") {
            gs.eventQueue('eventname', current, subject, responseBody);
        }
        current.work_notes = 'requestBody' + r.getRequestBody() + '\n\nhttpStatus: ' + httpStatus + '\n\nresponseBody: ' + responseBody;
    } catch (ex) {
        var message = ex.message;
    }
9 REPLIES 9

Hi @Ankur Bawiskar , 

Can you please explain?

Regards,

Babu

Hi,

where do they expect you to put the file's base64encoded string?

like this

{
  "firstname": "Max",
  "startdate": "2022-05-25",
  "email": "testcand0881@tester.com",
  "lastname": "Testmax",
  "fileData": "base64Data"
}

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar

Please bare with me, my requirement is to find a way to send the attachments to Azure Devops board along with the other details (short desc, desc, priority... etc) for an incident if and create a new Incident in azure board with this attachmen.

Incident > If 'Transfer to ADO' checkbox if checked > copy that incident details to Azure board and create a new ticket there via RST Messages, Currently it copies the data and also creates a new ticket in Azure board but I Need the attachments also to be copied to azure (where I am currently struck at) 

can we achieve this in any way?

 

Regards,

Babu

 

Hi,

So did you check Azure Devops API documentation?

The team with whom you are interacting ask them about this

how do they expect external applications to send attachments?

Azure DevOps Services REST API Reference

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Bhuvanesh Babu 

Hope you are doing good.

Did my reply answer your question?

If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader