Skip to content

APIM cannot retrieve policy using JavaScript SDK #31566

Open

Description

  • Package Name: JavaScript SDK
  • Package Version: latest stable
  • Operating system: windows
  • nodejs
    • version:
  • browser
    • name/version:
  • typescript
    • version:
  • Is the bug related to documentation :No

Describe the bug
A clear and concise description of what the bug is.
Hi this was logged to APIM team and was told to create a bug here. More details of the bug can be found in the internal icm portal
https://portal.microsofticm.com/imp/v5/incidents/details/557079604/summary

Cannot retrieve APIM API policy value using Azure SDK for JavaScript.

This is the customer verbose for full transparency:
We have issue with the APIM Javascript SDK
We try to read the policy in the API but we don't get back PolicyContract.

client.apiPolicy.get(
resourceGroupName,
serviceName,
apiId,
policyId,
{ format: 'rawxml' },
),

Does not return PolicyContract value

client: ApiManagementClient
library: '@azure/arm-apimanagement': '9.0.0'

--

'policyContract': { 'id': '/subscriptions/94486d6b-b366-4da1-b059-3883b469f51f/resourceGroups/apimgmt-dev-apim-we/providers/Microsoft.ApiManagement/service/apimgmt-dev-apim-01/apis/2895d73c-049e-405f-8c34-4a9d6f4eeef6/policies/policy', 'eTag': '\'AAAAAAAhguU=\'', 'name': 'policy', 'type': 'Microsoft.ApiManagement/service/apis/policies', 'format': 'xml' }

by contract it should return:
/** Current entity state version. Should be treated as opaque and used to make conditional HTTP requests. /
eTag?: string;
/
* Contents of the Policy as defined by the format. */
value?: string;

/** Format of the policyContent. */
format?: PolicyContentFormat;

To Reproduce
Steps to reproduce the behavior:

  1. Install VS Code, Node and NPM if you don't have them already. Node should include NPM as well, link: https://nodejs.org/en/download/package-manager
  2. Save the following code as "getPolicy.js" (make sure to replace your subscription ID and resource name)
  3. Log in to Azure CLI using the terminal in VS code: az login --tenant 16b3c013-d300-468d-ac64-7eda0820b6d3 (replace with your own tenant ID)
  4. Run it by using "node getPolicy.js" in the terminal:
    Image

Image

Expected behavior
A clear and concise description of what you expected to happen.
Expected behavior is for this to return the policy.
this is the documentation: https://learn.microsoft.com/en-us/javascript/api/@azure/arm-apimanagement/apipolicy?view=azure-node-latest#@azure-arm-apimanagement-apipolicy-get

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
log level was set to verbosity to get the exact call being made and made exactly the same request through postman and got the policy value so this seems contract mapping issue in the SDK code and need a fix.Image
same call postman
Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Labels

API ManagementMgmtThis issue is related to a management-plane library.Service AttentionWorkflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions