Abhishek Rai
Abhishek Rai

Reputation: 2227

Curl giving error 411 when calling Azure DevOps API

I have tried various values for the Content-Length, Tried removing it altogether, setting it at 0, however, I still end up with the same message, not really sure what is causing this. The token is a base64 encoded with ASCII charset. Not sure if that is relevant.

curl -s -X POST https://dev.azure.com/xxx-Updates/_apis/hooks/subscriptions?api-version=5.0 \
             -H 'Accept: application/json' \
             -H 'Content-Type: application/json' \
             -H 'Authorization: Basic WJxcnV2bXRwZWZyY2d6dmJ2NDR3M3F3azVkaHVkdG01dmE1a2pvemprcDM2Ymc1eWptYQ==' \ 
             -d '{"publisherId": "tfs", "eventType": "workitem.created","scope": "all", "resource": {"id": 5, "rev": 1, "fields": {"System.AreaPath": "Any","System.WorkItemType": "Feature", "System.State": "New"},"url": ""},"resourceVersion": "1.0"}'

Error:-


HTTP Error 411. The request must be chunked or have a content length.

Upvotes: 0

Views: 895

Answers (1)

Andy Li-MSFT
Andy Li-MSFT

Reputation: 30372

What OS are you using? Windows or Linux?

According to my test, I can reproduce the issue on Windows OS with the same format settings.

enter image description here

However, it works by replacing single quotes with double quotes:

curl -s -X POST -L https://dev.azure.com/xxx/_apis/hooks/subscriptions?api-version=6.0 -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Basic OnUzcHBuZjUzdnFid3l3RyZ3FvYXRmeDJ3Z3JtNDN6dW10ZmJpd3FtZXE=" -d '{"consumerActionId":"httpRequest","consumerId":"webHooks","consumerInputs":{"url":"https://requestbin.com/r/envu0xpxxxx"},"eventType":"workitem.created","publisherId":"tfs","publisherInputs":{"areaPath":"","workItemType":"Feature","projectId":"757d8384-e2a3-41a9-bc07-55fa40adf692"},"resourceVersion":"1.0","scope":1}'

You can have a try for that.

Besides, you can also try to run the same curl command from reqbin. If it works, then there should be something wrong with your local environment. enter image description here

Upvotes: 1

Related Questions