I am trying to make a call to below URL and it works just fine in Browser (Chrome) and also in Postman, but for some reason, it doesn\'t work in C#.
Working in b
RestClient constructor accepts URI that doesn't include userinfo
userinfo host port
┌──┴───┐ ┌──────┴──────┐ ┌┴┐
https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top
└─┬─┘ └───────────┬──────────────┘└───────┬───────┘ └───────────┬─────────────┘ └┬┘
scheme authority path query fragment
See: https://en.wikipedia.org/wiki/Uniform_Resource_Identifier
In order to make it work with RestSharp, we'll need to do a little bit of extra work here:
// Old:
// var client = new RestClient("http://AJWKBLWT47VR26QWPNFCPJLXC6217F6F@presta.craftingcrow.com/api/categories");
// New:
var client = new RestClient("http://presta.craftingcrow.com/api/categories")
{
Authenticator = new HttpBasicAuthenticator("AJWKBLWT47VR26QWPNFCPJLXC6217F6F", "")
};