Estou tentando capturar uma imagem da câmera VIPS3020 G2 através da URL http://192.168.0.13:80/cgi-bin/snapshot.cgi?channel=1 onde:
192.168.0.13 = ip da câmera
80 = servidor
Ao inserir esta URL pelo Postman ou pelo navegador (Chrome ou Internet Explorer), a requisição retorna corretamente (Status 200) juntamente com a imagem.
Porém, ao realizar a mesma requisição pelo navegador, é retornado o seguinte erro:
{StatusCode: 500, ReasonPhrase: 'Internal Server Error', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
Connection: close
Content-Length: 0
}}
Segue código abaixo:
Código: Selecionar todos
private static readonly string _cameraUsername = ConfigurationManager.AppSettings["CameraUsername"].ToString();
private static readonly string _cameraPassword = ConfigurationManager.AppSettings["CameraPassword"].ToString();
private HttpClient _httpClient { get; set; }
public WebHttpClient(HttpClient httpClient)
{
_httpClient = httpClient;
_httpClient.DefaultRequestHeaders.Add("Authorization", "Basic " + _cameraUsername + ":" + _cameraPassword);
}
public async Task<byte[]> GetByteArrayAsync(string uriPath)
{
try
{
_httpClient.MaxResponseContentBufferSize = 101500;
var httpResponse = await _httpClient.GetAsync(uriPath);
return new byte[10];
// return httpResponse;
}
catch(Exception ex)
{
var url = $"{_httpClient.BaseAddress}{uriPath}";
var teste = ex;
return new byte[10];
}
}
Response Headers do navegador:
Cache-Control: no-cache
CONNECTION: close
CONTENT-LENGTH: 100744
Content-type: image/jpeg
Pragma: no-cache