Skip to content Skip to sidebar Skip to footer

How To Make Raw Rest Call For Azure Using Python

I am trying to make REST Call for azure using python, Have created Access token using ADAL in python. But getting Error called 'provided Authorization header is in invalid format.'

Solution 1:

As @GauravMantri said, the format of the value of the header Authorization is Bearer <access-token> that you can refer to the section Calling ARM REST APIs of the doc "Resource Manager REST APIs".

For example in the section above.

GET /subscriptions/SUBSCRIPTION_ID/resourcegroups?api-version=2015-01-01 HTTP/1.1 Host: management.azure.com Authorization: Bearer YOUR_ACCESS_TOKEN Content-Type: application/json

Solution 2:

You would need to prepend Bearer to your token. Something like:

headers = {'Content-Type': 'application/json',
          'Authorization': 'Bearer ' + access_token}

Post a Comment for "How To Make Raw Rest Call For Azure Using Python"