I am writing a powershell script and trying to run a post command with an Azure DevOps api, but one of my values contains non-english characters and the Invoke-RestMethod always fails with:
{"$id":"1","innerException":null,"message":"You must pass a valid patch document in the body of the request.","typeName":"Microsoft.VisualStudio.Services.Common.VssPropertyValidationException, Microsoft.VisualStudio.Services.Common","typeKey":"VssPropertyValidationException","errorCode":0,"eventId":3000}
If I remove the non-english chars, it works as expected.
What do I need to do, to get the non-english chars to be accepted in the json body.
Figured it out. Just needed to add ";charset=UTF-8" to my content type.
Related
I've created a CloudFormation template that creates an instance. I want to pass a PowerShell script into a windows instance via the user data; however, when it's encoded with Base64, the Cloudformation template does not decode it correctly.
I want to pass in this:
Set-DNSClientServerAddress -InterfaceIndex (Get-NetAdapter).InterfaceIndex -ServerAddresses ("172.31.15.30")
When I check the template in the CloudFormation it got decoded as:
Set-DNSClientServerAddress /u2013InterfaceIndex (Get-NetAdapter).InterfaceIndex /u2013ServerAddresses ("172.31.15.30")
When this is passed into the Windows instance, it doesn't recognize /u2013, and errors out.
How do I ensure the line I pass in keeps the dash, rather than decode it into Unicode.
Could you try this?
"Set-DNSClientServerAddress \-InterfaceIndex (Get-NetAdapter).InterfaceIndex \-ServerAddresses ("172.31.15.30")"
Based on others needing to escape other characters: AWS Cloudformation output double quotes in a file using Fn::Join
\u2013 is a different type of unicode dash character. Your editor probably used it because it looks nicer. Try editing your source code with notepad or a simple editor and replace that unicode dash with a proper dash. If you are having a hard time typing it, you can copy it from Set-DNSClientServerAddress. That one seems fine.
I have a doubt. It's regarding Base64 encoding of one particular String.
We have an application which allows REST WebServices to be executed after authorization of type Basic Authentication is successful.
I has set the password for a user USER_NAME with the password CP#5N0v22nD17RrV8f4.
From my system, using Postman/Advanced REST client, the request sent is processed successfully. But the same request fails when made most of the other systems using the same REST client.
When I set this password to another user, that user credentials is facing the same problem.
I noticed that the Base64 encoding Output Charset is the problem. But there is no method to change it in the REST clients (not in the most of the ready-made ones).
But why is this happening only for this particular password. I check with every other passwords and it works fine.
String: USER_NAME:CP#5N0v22nD17RrV8f4
UTF-8: VVNFUl9OQU1FOkNQQDVOMHYyMm5EMTdSclY4ZjTigIs=
Windows-1252: VVNFUl9OQU1FOkNQQDVOMHYyMm5EMTdSclY4ZjQ=
ASCII: VVNFUl9OQU1FOkNQQDVOMHYyMm5EMTdSclY4ZjQ=
Only for CP#5N0v22nD17RrV8f4 the UTF-8 output charset encoding in Base64 is giving a different result.
Using any other passwords, all the outputs are the same.
Please make me understand why CP#5N0v22nD17RrV8f4 is different from the rest of the strings.
Thanks in Advance
Balu
The string has a non breaking space at the end of the string.
I tested this using the following steps.
Decoded the UTF-8 string VVNFUl9OQU1FOkNQQDVOMHYyMm5EMTdSclY4ZjTigIs= at https://www.base64decode.org/
Copied the result to encode in UTF-8 at https://www.base64decode.org/, but this time pressed backspace once at the end of string. Gives me output VVNFUl9OQU1FOkNQQDVOMHYyMm5EMTdSclY4ZjQ=
You could also try typing the characters manually, and encoding.
I guess this is a simple question, but I have found no reference. I have a small lex file defining some tokens from a string and altering them (actually converting them to uppercase).
Basically it is a list of commands like this:
word {setToUppercase(yytext);}
Where setToUppercase is a procedure to change case and store it.
I need to have the complete entry string with the altered words. Is there a way to define a default token / rest of tokens so I can asociate them with an unaltered storage in an output string?
You can do that in one shot with:
.|\n {save_str(yytext);}
I said it was an easy one.
. {save_str(yytext);}
\n {save_str(yytext);}
This way all characters and newline are treated.
Trying to use Grunt FTP deploy plugin. Have an FTP password with the characters !,#,%,# and can't seem to find which of and how these need to be escaped.
I've tried wrapping the entire password string in single-quotes and \ escaping each character. In the former case I still get and auth failed error; in the latter case, I get an error like "Unexpected token #".
README.md
IMPORTANT: make sure that the .ftppass file uses double quotes (which is the proper JSON syntax) instead of single quotes for the
names of the keys and the string values.
String
Series of characters (letters, numbers, or symbols); double-quoted
UTF-8 with backslash escaping.
I know it is an old question but I just had this problem and finally found a solution.
My CLI is Windows and my problem was related a batch script where the password for my SFTP (using PSFTP) had special charachters.
I solved it escaping the password with the rules described here:
https://www.robvanderwoude.com/escapechars.php
The password was "X5d2KeY6%0123ghjy".
The password became "X5d2KeY6%%0123ghjy" (that is, % became %%).
I am trying to parse some data using nsxmlparser, whenever there is a &(ampersand) present in the text being received it just stops reading the parsed data. How can I read & normally, similar to other normal characters.
Thanks
Pankaj
A lone ampersand in an XML document is not valid except in a CDATA section. You can either have your XML provider provide valid XML by either:
Using the & character entity where you want ampersands.
Putting text containing ampersands into a CDATA section.
Could not find the solution so i had to replace the & with some characters in backend and then again replace it in iphone while using it