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
- README.md
- source code documentation
- SDK API docs on https://learn.microsoft.com
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:
- 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
- Save the following code as "getPolicy.js" (make sure to replace your subscription ID and resource name)
- 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)
- Run it by using "node getPolicy.js" in the terminal:
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.
same call postman