-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
APIM cannot retrieve policy using JavaScript SDK #31566
Comments
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @miaojiang. |
will check |
I can repo this issue, and I tried to use rest api to investigate, @shivshankar1111 I can't find the response from the screenshot of the log with verbosity level , could you re-upload? |
Hi @shivshankar1111. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue. |
Hi @shivshankar1111, we're sending this friendly reminder because we haven't heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you! |
Yes looks like customer is looking for policy value as response. |
I try to set the request header like service defined three content-type in rest https://github.com/Azure/azure-rest-api-specs/blob/main/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/apimapis.json#L2620-L2624 may have some issues in sdk analysis |
@shivshankar1111 Can you try to create the client like below import { parseXML } from "@azure/core-xml";
const client = new ApiManagementClient(credential, subscriptionId, {
deserializationOptions: {
expectedContentTypes: {
xml:["application/vnd.ms-azure-apim.policy+xml"]
},
parseXML: parseXML
}} as any); And pass the accept headers in the operation options const result = await client.apiPolicy.get(
resourceGroup,
resourcename,
apiId,
policyId,
{format: "xml", requestOptions: {customHeaders: {Accept: "application/vnd.ms-azure-apim.policy+xml"}}}
); and see if it satisfies your requirement? @xirzec I found the deserializationOptions are not really being exposed to our customer, that's why we have the And core-client doesn't provide a default parser for xml kinda content type, however we do have core-xml library now, wonder if we should remove the limitation here
|
Is there value in the SDK actually parsing the XML value into JSON or can we simply return it to the customer as a string like how it is sent over the wire?
XML isn't built into core-client like it was in core-http since it was a very large dependency for the bundle size and most services do not need it. |
The mapper even lists the value as a simple string:
So it would work just fine, except the operation says it's XML when it's not: azure-sdk-for-js/sdk/apimanagement/arm-apimanagement/src/operations/apiPolicy.ts Line 228 in 7d256c7
I think if we removed |
Workaround is to use policy.lisByApi() method, which returns the policies, but requires more coding around it to parse the response |
will try to remove isXML and try again |
@shivshankar1111 we have released a new version here https://www.npmjs.com/package/@azure/arm-apimanagement/v/9.2.0 to fix this issue, could you try to use this package to verify? thanks |
Hi @shivshankar1111. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue. |
Hi @shivshankar1111, we're sending this friendly reminder because we haven't heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you! |
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;
To Reproduce
Steps to reproduce the behavior:
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
The text was updated successfully, but these errors were encountered: