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?Mani– Mani2016-05-24 09:27:03 +00:00Commented 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.Dipak J– Dipak J2016-05-24 09:34:34 +00:00Commented 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 SOAPUIDipak J– Dipak J2016-05-24 09:37:44 +00:00Commented 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 APIDipak J– Dipak J2016-05-24 09:39:08 +00:00Commented May 24, 2016 at 9:39
- Are you passing in an authentication token in the authorization header?Mani– Mani2016-05-24 10:08:16 +00:00Commented May 24, 2016 at 10:08
| Show 5 more comments
1 Answer
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