Hi
I am in the need of, some serious help
I am working on a small PowerShell GUI, that gets data from a couple of WEB services..
but when I get the data, it is not in the right encoding, it should be UTF8 but it is not when Invoke-WebRequest have been handling it.
I can se that there is a lot of posts about this on the internet, but I have not had any success fixing the encoding on the UTF8 data that is getting back from the webservices..
Could anyone help me with an alternative way of getting the data or an idear how I fix the data when invoke-webrequest have delivered them in a bad format.
I have tried with the different ways with getbytes and loops..
but it does not fix my encoding
thanks on adwance
/Graves
Wrong encoding from - Invoke-WebRequest
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Wrong encoding from - Invoke-WebRequest
You have to accept the encoding of the web service. Save it to a file and convert the file.
IWR returns an object that has the raw data embedded. Different web services return different objects. The tezt in the object properties will be as inserted by the web service and in that encoding.
IWR returns an object that has the raw data embedded. Different web services return different objects. The tezt in the object properties will be as inserted by the web service and in that encoding.
Re: Wrong encoding from - Invoke-WebRequest
Hi
Thanks for the idea's.
Got it working writing a file, and reading it again..
It was the quick fix, but I will try work with the New-WebServiceProxy when I modify my code
/Graves
Thanks for the idea's.
Got it working writing a file, and reading it again..
It was the quick fix, but I will try work with the New-WebServiceProxy when I modify my code
/Graves
Re: Wrong encoding from - Invoke-WebRequest
JUst note that what you get back from "Invoke-WebRequest" is an object and cannot be displayed as text. If you output to a file the web page is converted to text so it will be readable. The issue is as I noted above, the objects text from the remote server does not have a BOM so it won't convert correctly but the Invoke-Command has teh ability to use the object to detect the encoding and convert it correctly in most cases.
Again, WebRequest is not the correct command to use for a web service. You want to use the correct command and all of this goes away. The other issue is that you have not given any indication of why you are using an HTML browser emulator to query a web service. Most of the object is useless and the "contents" property contains the web service response as plain text and in the correct encoding for PowerShell.
Again, WebRequest is not the correct command to use for a web service. You want to use the correct command and all of this goes away. The other issue is that you have not given any indication of why you are using an HTML browser emulator to query a web service. Most of the object is useless and the "contents" property contains the web service response as plain text and in the correct encoding for PowerShell.