any way to suppress \ or / encoding as %2C or %5F by Invoke-WebRequest?!?

Copper Contributor

I'm trying to use Invoke-WebRequest, from PS 7.2 on current Windows 10--so .Net v ???, to communicate with a device. The device that has an API parameter that likes embedded \ or / (it's agnostic--I've tested both from a browser) but fails with %2F or %5C. Invoke-WebRequest seems to insist on encoding my -Body "path\file" parameters with the %2F or %5C no matter what combination of them I try when I make the hashtable I feed to -Body.


I've seen some Google traffic on this, and on possible workarounds that look beyond my understanding (some mumble about mucking with internal flags on [System:UriParser] via reflection) and much discussion of different .Net versions having different behaviors in this area.


Is there a straightforward workaround?

0 Replies