Quantcast
Channel: Preguntas activas con las etiquetas mercadopago - Stack Overflow en español
Viewing all articles
Browse latest Browse all 213

C# POST API Mercado Pago con codigo QR

$
0
0

necesito ayuda, estoy intentando enviar un Header al contenido de una peticion POSTa mercado pago para utilizar el codigo QR en c#,pero tengo un problema que dice como que estoy introduciendo el header donde "no va" y me tira el siguiente error:

System.InvalidOperationException: 'Misused header name, 'Authorization'. Make sure request headers are used with HttpRequestMessage, response headers with HttpResponseMessage, and content headers with HttpContent

mi codigo es el siguiente:

     string Url = $"https://api.mercadopago.com/mpmobile/instore/qr/47986885/CAJA0001";            var Client = new HttpClient();            Client.DefaultRequestHeaders.Authorization =                     new AuthenticationHeaderValue("Bearer", "MI_ACCESS_TOKEN");            CapaNegocios.Pagos.MPCheckout oTransaccion = new CapaNegocios.Pagos.MPCheckout()            {                sku_number = "12345",                category = "Categoria1",                title = "TiruloPrueba",                description = "DescripcionPrueba",                unit_price = 22,                quantity = 1,                unit_measure = "No se que es",                total_amount = 22            };            var requestt = @"{{'external_reference': '12345','title': 'Product order','notification_url': 'www.yourserver.com','total_amount': 100,'items': [{'sku_number': 'KS9999','category': 'UTILIDAD','title': 'Lapicera','description':'lapicera verde','unit_price': 100,'quantity': 8,'unit_measure': 'unit','total_amount': 800                      }                    ],'taxes': [                      {'value': 19,'type': 'IVA'                      }                    ],'sponsor': {'id': 446566691                    },'cash_out': { }               }            }";            requestt = requestt.Trim();            var Datas = JsonSerializer.Serialize(requestt);            var Data = JsonSerializer.Serialize<CapaNegocios.Pagos.MPCheckout>(oTransaccion);            HttpContent contenido = new StringContent(Datas, Encoding.UTF8, "application/json");             contenido.Headers.Add("Authorization", "MI_ACCESS_TOKEN"); // ACA NECESITO METER EL HEADER!!!!            var httpResponse = await Client.PostAsync(Url, contenido);            if (httpResponse.IsSuccessStatusCode)            {                var Resultado =await httpResponse.Content.ReadAsStringAsync();            }

Como bien dije y especifique en el codigo, necesito meter el HEADER por lo que estoy viendo en el HttpContent(contenido),alguno sabe como solucionar esto?Desde ya muchas gracias


Viewing all articles
Browse latest Browse all 213

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>