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

%3CLINGO-SUB%20id%3D%22lingo-sub-2260023%22%20slang%3D%22en-US%22%3Eany%20way%20to%20suppress%20%5C%20or%20%2F%20encoding%20as%20%252C%20or%20%255F%20by%20Invoke-WebRequest%3F!%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2260023%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20trying%20to%20use%20Invoke-WebRequest%2C%20from%20PS%207.2%20on%20current%20Windows%2010--so%20.Net%20v%20%3F%3F%3F%2C%20to%20communicate%20with%20a%20device.%20The%20device%20that%20has%20an%20API%20parameter%20that%20likes%20embedded%20%5C%20or%20%2F%20(it's%20agnostic--I've%20tested%20both%20from%20a%20browser)%20but%20fails%20with%20%252F%20or%20%255C.%20Invoke-WebRequest%20seems%20to%20insist%20on%20encoding%20my%20-Body%20%22path%5Cfile%22%20parameters%20with%20the%20%252F%20or%20%255C%20no%20matter%20what%20combination%20of%20them%20I%20try%20when%20I%20make%20the%20hashtable%20I%20feed%20to%20-Body.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI've%20seen%20some%20Google%20traffic%20on%20this%2C%20and%20on%20possible%20workarounds%20that%20look%20beyond%20my%20understanding%20(some%20mumble%20about%20mucking%20with%20internal%20flags%20on%20%5BSystem%3AUriParser%5D%20via%20reflection)%20and%20much%20discussion%20of%20different%20.Net%20versions%20having%20different%20behaviors%20in%20this%20area.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20there%20a%20straightforward%20workaround%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2260023%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EWindows%20PowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
New 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