-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
az rest breaks when JSON parameter value has a space in it #22550
Comments
route to CXP team |
@cResults |
Hello @cResults Could you please confirm if you are using the quotes for the value "BuildInitiatorName"? Wanted to check if adding quotes to the value resolve this issue/ |
@SatishBoddu-MSFT Thank you for giving this prompt attention. I'm not sure what you are asking. The code as recorded above is failing. Is there some place in the code block of the "To Reproduce" section that is missing quotes? As far as I can tell from printing out the body variable right before calling az rest, everything I'd expect to be escaped and quoted including the BuildInitiatorName's value is escaped and quoted? Please let me know if i answered your question. I appreciate the dialog and will try any changes you recommend. |
Hello @cResults Thanks for sharing more information on this, we are routing this to the Service Teams Attention! |
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Stefanus Hinardi, @Francisco-Gamino. Issue DetailsRelated command Describe the bug To Reproduce
Expected behavior Environment summary Dependencies: Additional context
To me that looks like json that one would expect to succeed being passed as body content in a rest request, though typically without the escape \ characters. The error thrown in the logs looks like
Notice that it appears to remove the first part of the object; the opening { and first property name. Also the position of the property which contains a space in its value doesn't seem to matter. Originally, the BuildInitiatorName property was near the bottom of the list, but the error message looked the same with the opening { and first property name missing. Remove the BuildInitiatorName property and the request completes successfully. Populate BuildInitiatorName value with "John_Doe" and the request completes successfully. Populate BuildInitiatorName value with "John Doe" and the request fails. I'm new to Azure CLI and while I was excited when I finally got the call to our Azure Function working without needing to access key vault or putting access credentials in our code repository, it was a struggle creating this json body in powershell in a way that would work. But it did work awesomely. Then I needed to add the BuildInitiatorName into the request and it started failing with the error described herein and I have been beating my head against numerous Google and Bing searches trying to find the right question to ask to be able to find a way to make this work, but with no success. Ultimately, one of those searches brought me to your GitHub repo and I'm hoping you can help. Either this is a bug or else it must be doable. Thank you for any assistance you can give.
|
Related command
az rest
Describe the bug
passing az rest a json body object with a property that has a space in the value throws ERROR: unrecognized arguments:
To Reproduce
Whenever any of the string variables below contain an empty space, the error will be thrown. For example, when the triggerPipeRequestedFor variable equals "John Doe", the error will be thrown, but if I manually set the value replacing the space with an underscore "John_Doe" the az rest request succeeds.
Expected behavior
Expect to be able to pass a typical json body to az rest and have the request complete.
Environment summary
The AzureCLI@2 task is being executed on a Windows Server 2019 VM in Azure.
azure-cli 2.34.1 *
core 2.34.1 *
telemetry 1.0.6
Dependencies:
msal 1.16.0
azure-mgmt-resource 20.0.0
Additional context
echo body: $body
in the powershell snippet above writes the followingecho bodyCompressed: $body
in the powershell directly before calling az rest writes the followingTo me that looks like json that one would expect to succeed being passed as body content in a rest request, though typically without the escape \ characters.
The error thrown in the logs looks like
Notice that it appears to remove the first part of the object; the opening { and first property name. Also the position of the property which contains a space in its value doesn't seem to matter. Originally, the BuildInitiatorName property was near the bottom of the list, but the error message looked the same with the opening { and first property name missing.
Remove the BuildInitiatorName property and the request completes successfully. Populate BuildInitiatorName value with "John_Doe" and the request completes successfully. Populate BuildInitiatorName value with "John Doe" and the request fails.
I'm new to Azure CLI and while I was excited when I finally got the call to our Azure Function working without needing to access key vault or putting access credentials in our code repository, it was a struggle creating this json body in powershell in a way that would work. But it did work awesomely. Then I needed to add the BuildInitiatorName into the request and it started failing with the error described herein and I have been beating my head against numerous Google and Bing searches trying to find the right question to ask to be able to find a way to make this work, but with no success. Ultimately, one of those searches brought me to your GitHub repo and I'm hoping you can help. Either this is a bug or else it must be doable.
Thank you for any assistance you can give.
The text was updated successfully, but these errors were encountered: