Postman request vs Local (server) request

65 Views Asked by At

I'm developing a C# application to communicate with an external API. I'm using HttpClient to send requests to that API. The question is:

  • If I make the request through Postman or even through my application (but with Fiddler open) I get a response with 200 code and with the information I want.
  • If I make the request through my application (which is running on localhost) or even through PowerShell, I get code 403.

PS: The code I'm using in C# was generated by Postman.

Postman Request

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://betting.begmedia.pt/api/v2/me/bets/ended");
        request.Headers.Add("X-Client", secretToken);
        request.Headers.Add("User-Agent", "PostmanRuntime/7.36.0");
        
        var response = await client.SendAsync(request);
        response.EnsureSuccessStatusCode();
        Console.WriteLine(await response.Content.ReadAsStringAsync());`
0

There are 0 best solutions below