1

I am calling Azure's REST API to get 'List all available virtual machine sizes in a region' from SOAPUI but it gives me error in response.. {"error": { "code": "AuthenticationFailedInvalidHeader", "message": "Authentication failed. The 'Authorization' header is provided in an invalid format." }} I have set the Authorization header too..

10
  • Can you provide sample of code used? Commented May 24, 2016 at 9:27
  • actually I have written nothing code for it.. I just picked up one azure api and trying to call using SOAPUI. Commented May 24, 2016 at 9:34
  • I am going to provision VM in our project so that's why I'm checking or testing it through SOAPUI Commented May 24, 2016 at 9:37
  • "management.azure.com/subscriptions{subscription-id}/providers/Microsoft.Compute/locations/{location}/vmSizes?api-version={api-version}" - this is the API Commented May 24, 2016 at 9:39
  • Are you passing in an authentication token in the authorization header? Commented May 24, 2016 at 10:08

1 Answer 1

0

The api need authentication, so you need to configure SoapUI with client certificate authentication. Your api has no problem. I test your api successfully using powershell.

 Add-Type -Path 'C:\Program Files\Microsoft Azure Active Directory Connect\Microsoft.IdentityModel.Clients.ActiveDirectory.dll' $context = New-Object Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext ("https://login.windows.net/tenantid/") $cred = New-Object Microsoft.IdentityModel.Clients.ActiveDirectory.ClientCredential ("clintid", "key") $result = $context.AcquireToken("https://management.core.windows.net/", $cred) $token = $result.AccessToken $authHeader = "Bearer $token" #$authHeader $headers = @{"Authorization"=$authHeader; "Content-Type"="application/json"} $size=Invoke-RestMethod -Method get -Uri "https://management.azure.com/subscriptions/subscriptionsid/providers/Microsoft.Compute/locations/location/vmSizes?api-version=2015-05-01-preview" -Headers $headers $size.value 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.