1

I'm targetting an API where I need to send a query string without URL encoding.

 response = await httpClient.GetAsync(uri).ConfigureAwait(false);

where uri could be something like this

https://xm001040.nxodev.intra/api/mgt/1.0/Node/140/Subscriber?attributes=Station_Type,Right_Profile_Name,Directory_Number&Query[Set_Role][=]=Profile_Role

That works fine on our dev boxes, both Win10 and a 2012R2 server (all using VS2017). However, if we deploy the application on a Win2016 server without dev environment, the sqme uri is no longer sent as-is, but is instead converted into

https://xm001040.nxodev.intra/api/mgt/1.0/Node/140/Subscriber?attributes=Station_Type,Right_Profile_Name,Directory_Number&Query%5BSet_Role%5D%5B=%5D=Profile_Role

Is there a way I can tell the httpClient to leave my uri alone that works everywhere? The lib where this is done is a .NET standard 2.0 lib, it is consumed by a .NET standard 4.6.1 app

user3566056
  • 224
  • 1
  • 12
  • 1
    Take a look at the answer from @JasonM1 in https://stackoverflow.com/questions/1547899/which-characters-make-a-url-invalid. Those brackets are characterized as "unwise" to use in a URL. You should talk to the API guys; Windows Server is a pretty common operating system – Flydog57 Jul 12 '18 at 22:11
  • I realize the characters are unwise - unfortunately it's a private API and external use is just tolerated, not even supported. It turns out the problem isn't the server, but the way we launch the app. When launched from our service wrapper, the url is being modified, launch the exe directly and the url remains as it so I have to look into what our service wrapper does differently. – user3566056 Jul 13 '18 at 12:08
  • I managed to track down the issue. Our service wrapper Windows service was compiled with .NET 4.0. I changed the output to 4.6.1 matching the output of the app it is running as a service, and suddenly the problems were gone. – user3566056 Jul 17 '18 at 07:53

0 Answers0