I have the following simple GET request with Basic Auth that works fine from Postman:
I then just copy/paste the C# - RestSharp code snippet from postman into a simple console application:
class Program
{
static void Main(string[] args)
{
var client = new RestClient("https://.....");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("X-CSRF-Token", "Fetch");
request.AddHeader("Authorization", "Basic U0.....==");
IRestResponse response = client.Execute(request);
....
but the response is: 401 Not Authorized
.
I've always used the auto-generated snippets form Postman with no problems so far. But now I'm facing this issue, apparently sth is missing from the request made with C# code.
Any advice or pointers would be much appreciated!
UPDATE: Using curl on windows 10 the request works ok. This is what I used:
curl --location --request GET "https://....." --header "X-CSRF-Token: Fetch" --header "Authorization: Basic ......"
The auth token is exactly the same in both cases, in curl it works in RestSharp it doesn't.