rest - Invoke-RestMethod converts backslash to slash -


i call rest api passing parameter contains backslash character.

the api expects route api/test/<app_name>/<user_name>, , example pass domain\login value user_name.

i tried powershell:

$uri = [uri]::escapeuristring("http://localhost:5555/api/test/app name/domain\login") # $uri = 'http://localhost:5555/api/test/app%20name/domain%5clogin' invoke-restmethod -method -uri $uri -verbose 

the output of invoke-restmethod -verbose flag shows powershell is converting backslash slash, , after 404 rest api (which expected since route not match):

verbose: http://localhost:5555/api/test/app name/domain/login 0-byte payload invoke-restmethod : 404 not found 

how can avoid behavior , use path encoded backslash?

here output of $psversiontable variable:

> $psversiontable  name                           value ----                           ----- psversion                      5.1.14393.953 psedition                      desktop pscompatibleversions           {1.0, 2.0, 3.0, 4.0...} buildversion                   10.0.14393.953 clrversion                     4.0.30319.42000 wsmanstackversion              3.0 psremotingprotocolversion      2.3 serializationversion           1.1.0.1 

what should word: replace / // maybe must define regular string , convert it:

$rawuri = 'http://...' 

here should use // instead of /.

then use code , replace text new variable.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -