I am trying to make a POST request to Azure DevOps API using curl code within a terraform script.
resource "null_resource" "AzDo_API_request" {
provisioner "local-exec" {
command = <<EOT
curl -L -X POST "https://dev.azure.com/altabhussain0027/_apis/hooks/subscriptions?api-version=7.1-preview.1"
-H "Authorization: Basic OnBobHdxcm1sb2Fvb3ZwZDZmbHZobjdiMnNoYXJ2aTRqdWNsYjJqNnpyemQ3dG9jYWh0eGE="
-H "Content-Type: application/json"
--data-raw "{
\"consumerActionId\": \"httpRequest\",
\"consumerId\": \"webHooks\",
\"consumerInputs\": {
\"url\": \"https://pulse-xxx.com/webhook/c29ac65b-xxxx-xxxx-xxxx-f4dc16d3114e\"
},
\"eventType\": \"workitem.updated\",
\"publisherId\": \"tfs\",
\"publisherInputs\": {
\"areaPath\": \"any\",
\"workItemType\": \"Feature\",
\"projectId\": \"b0eb9e33-xxxx-xxx-xxxx-68866d0dd821\"
},
\"resourceVersion\": \"1.0\",
\"scope\": \"all\"
}"
EOT
}
}
The above curl code is generated from Postman wherein the POST request are successfull without giving error. However, when executing the same using terraform, I am getting the below error:
null_resource.AzDo_API_request (local-exec): curl: (3) URL using bad/illegal format or missing URL │ Error: local-exec provisioner error │ │ with null_resource.AzDo_API_request, │ on servicehook.tf line 2, in resource "null_resource" "AzDo_API_request":
I am running the above in Windows 11 machine, it might have to do with the double quotes. Any help is appreciated.