HTTP/1.1 401 Unauthorized

1.2k Views Asked by At

Below curl request throwing follwoing errors, any help here?

Thanks, Pradeep

curl -i -L -X PUT -cert ./certs/new-devices.cert.pem -key ./private/new-devices.key.pem -H 'Content-Type:application/json' -H 'Content-Encoding:utf-8' -d '{"registrationId":"sensor-thl-2001"}' https://global.azure-devices-provisioning.net/One00xxx/registrations/sensor-thl-2001/register?api-version=2019-03-31

curl: (6) Could not resolve host: . curl: (6) Could not resolve host: . HTTP/1.1 401 Unauthorized

1

There are 1 best solutions below

0
asergaz On

Please make sure you are configuring your Authorization HTTP header with a valid Bearer Token. In order to get it you first need to create a Service Principal in your Azure Tenant as very well documented here: How to call Azure REST APIs with curl