Reputation: 43
If I try to retrieve all subscriptions for a customer via Microsoft Partner API, I just get http error 500. We are direct Microsoft Partner, and I can get these subscriptions via Get-PartnerCustomerSubscription
PowerShell command.
My code looks like this:
$CustomerId = "CUSTOMERIDOFCUSTOMERINCSPPORTAL"
$Headers = @{
"Authorization" = "Bearer $($PartnerRefreshToken)"
"Accept" = "application/json"
}
$SubsUri = "https://api.partnercenter.microsoft.com/v1/customers/$CustomerId/subscriptions"
$SubsUriResponse = Invoke-RestMethod -Headers $Headers -Uri $SubsUri -Method GET
But I only get this generic error:
Invoke-RestMethod : { "statusCode": 500, "message": "Internal server error", "activityId": "73e5479e-0f8c-4ecd-a26f-055ac17e124c" }
At line:1 char:20
+ ... iResponse = Invoke-RestMethod -Headers $Headers -Uri $SubsUri -Method ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
I have tried to consult Microsoft API documentation, but I do not find any answers, and I cannot seem to figure out if my request is not formatted correctly.
Upvotes: 2
Views: 417
Reputation: 43
I tried again and error persisted. I then changed my header to this:
$PartnerAuthHeaders =
@{Authorization = ("Bearer {0}" -f $newPartnerToken.AccessToken) }
And switching to using the AccessToken instead of the 90 days refreshToken, and now it works.
Upvotes: 2