none
Error en solicitud Post a Rest Api C# RRS feed

  • Pregunta

  • hola...

    Desarrollando una solicitud a una REST API me devuelve el siguiente error :

    StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
    {
      Transfer-Encoding: chunked
      Connection: keep-alive
      X-Content-Type-Options: nosniff
      CF-RAY: 3c5ef77a5a5e2e69-MIA
      Date: Thu, 30 Nov 2017 15:51:12 GMT
      Set-Cookie: __cfduid=d64afd1daa19e4f0547d897a69016b8991512057071; expires=Fri, 30-Nov-18 15:51:11 GMT; path=/; domain=.comprobanteselectronicos.go.cr; HttpOnly
      Server: cloudflare-nginx
      Content-Type: text/plain; charset=utf-8
    }

    Mi Codigo:

     public async Task PostParametrizadoAsync()
        {
            HttpClient client = new HttpClient();
            client.BaseAddress = new Uri("https://api.comprobanteselectronicos.go.cr/recepcion-sandbox/v1/");
            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "/path");
    
            var byteArray = new UTF8Encoding().GetBytes("<api-stag>:<all>");
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
    
            var formData = new List<KeyValuePair<string, string>>();
            formData.Add(new KeyValuePair<string, string>("grant_type", "password"));
            formData.Add(new KeyValuePair<string, string>("username", "<asedr7328@stag.comprobanteselectronicos.go.cr>"));
            formData.Add(new KeyValuePair<string, string>("password", "<3453fsgdfg>"));
            formData.Add(new KeyValuePair<string, string>("scope", "all"));
    
            request.Content = new FormUrlEncodedContent(formData);
            var response = await client.SendAsync(request);
            richTextBox1.Text = response.ToString();
        }


    EFRAIN MEJIAS C VALENCIA - VENEZUELA

    jueves, 30 de noviembre de 2017 15:52

Respuestas