I'm trying to make a POST request to Azure with the following code:
import requests
api_url = https://management.azure.com/subscriptions/subscription_id/resourcegroups/resourcegroup_id/providers/Microsoft.DataFactory/factories/datafactory_id/airflow/sync?api-version=2018-06-01"
todo = {
"IntegrationRuntimeName": "Airflow",
"LinkedServiceName": "LAIRFLOW",
"StorageFolderPath": "airflow/dev/",
"CopyFolderStructure": "true",
"Overwrite": "true",
}
response = requests.post(api_url, json=todo)
print(response.json())
print(response.status_code)
But I'm getting the following error:
{'error': {'code': 'AuthenticationFailed', 'message': "Authentication failed. The 'Authorization' header is missing."}}
401
I've tried to include the client and secret id:
response = requests.post(api_url, json=todo, auth=(AZURE_CLIENT_ID, AZURE_CLIENT_SECRET))
But I got the following error:
{'error': {'code': 'AuthenticationFailedInvalidHeader', 'message': "Authentication failed. The 'Authorization' header is provided in an invalid format."}}
401
How should I make the request?