Reputation: 1531
I'm having trouble retrieving the list of APIM Products from the REST API based on the "apiId" passed in. I tried using the IDENTIFIER value from the screenshot below:
However, I get the following error:
Invoke-RestMethod : {"error":{"code":"ResourceNotFound","message":"Api not found.","details":null}} At D:\powershell scripts\testing\test_add_api2.ps1:77 char:5 + Invoke-RestMethod -Method Get -Uri $url -Header @{ "Authorization ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-Rest Method], WebException + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMet hodCommand
I'm using the following path to retrieve the list of products:
https://{base url}/apis/{apiId}?api-version=2016-10-10
I've also verified that the access token is valid for 5 days out.
First, am I using the correct id for "apiId"? Second, has the path changed recently if I'm using the correct apiId?
Upvotes: 2
Views: 711
Reputation: 1531
After speaking with Microsoft support, I figured out the issue. It turns out there's two different documentations with "Product" in the title under the "Reference" section: (1) Api Products and (2) Products
I made the mistake of following the documentation under #1. #2 is the documentation you want to follow in order to get the list of products. According to that documentation, the path looks like this:
GET /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products?api-version=2016-10-10[&$filter&$top&$skip&expandGroups]
https://learn.microsoft.com/en-us/rest/api/apimanagement/products
I confirmed that this works. So in short, use documentation #2 for products, not #1. Not sure what #1 is used for, but #2 works.
Upvotes: 2