I am getting the following error when I try to curl Azure´s SendMail endpoint. The documentation is not really helpful. What am I doing wrong?
endpoint=https://dev.azure.com/myorg/myproject/_apis/wit/sendmail?api-version=7.1-preview.1
body='{
"message": {
"body": "Test Body",
"cc": {},
"to": {
"tfsIds": ["my-tfsIds-id"]
},
"replyTo": {},
"subject": "Test Subject"
},
projectId:"my-project-id"
}'
curl -X POST "$endpoint" --data "$body" -H "Authorization: Basic $pat" -H "Content-Type: application/json" -vL
Note: Unnecessary use of -X or --request, POST is already inferred.
* Closing connection -1
curl: (3) URL using bad/illegal format or missing URL
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Length Required</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Length Required</h2>
<hr><p>HTTP Error 411. The request must be chunked or have a content length.</p>
</BODY></HTML>
PS: I also get a redirect and I don´t really understand why either but I guess it´s the sign in authority?
* Connection #0 to host dev.azure.com left intact
* Issue another request to this URL: 'https://xxxxx.vssps.visualstudio.com/_signin?realm=dev.azure.com&reply_to=https%3A%2F%2Fdev.azure.com%2FMYORG%2FMYPRODJECT%2F_apis%2Fwit%2Fsendmail%3Fapi-version%3D7.1-preview.1&redirect=xxxxxxxxxxxxxxxxx'
* Switch from POST to GET
* Trying xx.xxx.xx.xx:443...
* Connected to xxxxx.vssps.visualstudio.com (xx.xxx.xx.xx:443) port 443 (#1)
Update
By including the Content-Length
header it now returns a 503..
Sorry! Our services aren't available right now.
We're working to restore all services as quickly as possible. Please check back soon.
To see the latest status on our services, please visit our support page.
I have used the below PowerShell script to invoke
POST https://dev.azure.com/{organization}/{project}/_apis/wit/sendmail?api-version=7.1-preview.1
and getting the email as expected.Please add
ids
for work item ids and correcttfIds
in your request body.Email-
References:- Azure DevOps SendMail Rest API returns 204 but doesn't send an email - Stack Overflow