1

I’m trying to send custom email messages using Azure devOPS Send Email REST API:

POST https://dev.azure.com/{organization}/{project}/_apis/wit/sendmail?api-version=7.1-preview.1

Unfortunately, the call keeps running into an error:

NET ERR & Console ERR

I'm still relatively new to this and can't find the error. I hope you can help me.

Here is my used code:

return new Promise(async function (resolve, reject) {

    const xhttp = new XMLHttpRequest();
    const pr = await getProject();

    xhttp.open('POST', 'https://vssps.dev.azure.com/bkaidi/'+pr!.id+'/_api/_wit/sendMail?__v=5', true)
    xhttp.setRequestHeader ("Authorization", "Basic " + btoa('Basic' + ":" + await SDK.getAccessToken()));
    xhttp.setRequestHeader("Content-Type","application/json");

    xhttp.onload = function() {
        if (this.readyState == 4 && this.status == 200) resolve(xhttp.response);
        else reject('err');
    };

    xhttp.onerror = function () { reject('err');};

    const json:any = {"message":"{\"to\":{\"tfIds\":[\"3cc146e6-038f-67a6-8d18-b0c933af005c\"],\"emailAddresses\":[],\"unresolvedEntityIds\":[]},\"subject\":\"cc\",\"body\":\"test\",\"cc\":{\"tfids\":[\"3cc146e6-038f-67a6-8d18-b0c933af005c\"]},\"replyTo\":{\"tfids\":[\"3cc146e6-038f-67a6-8d18-b0c933af005c\"]}}","wiql":"select [System.Id], [System.WorkItemType], [System.Title], [System.AssignedTo], [System.State], [System.Tags] from Workitems where [System.TeamProject] = @project and [System.WorkItemType] <> '' and [System.State] <> ''","fields":["System.Id;70","System.WorkItemType;75","System.Title;450","System.AssignedTo;125","System.State;75","System.Tags;200"],"runQuery":false,"persistenceId":"4c6bf803-3dbd-415c-ad64-b3812b303baa","format":1,"workItemIdFilter":[]}

    xhttp.send(JSON.stringify(json));
});
misha130
  • 5,457
  • 2
  • 29
  • 51
BIlal2412
  • 11
  • 1

0 Answers0