Witam. Próbuje dostać się do api przelewy24 poprzez basic auth, ale nie mogę przeskoczyć dodania do headera nagłówka uwierzytelniającego:
string sign = CalculateRegisterSign(model.sessionId, options.MerchantId, model.amount, model.currency, options.CRC);
string Body = CreateBodyForRegister(
options,
model,
sign,
string.IsNullOrEmpty(model.country) ? false : true,
string.IsNullOrEmpty(model.urlStatus) ? false : true);
string username = options.MerchantId.ToString();
string password = options.PrivateApiKey;
string svcCredentials = Convert.ToBase64String(ASCIIEncoding.UTF8.GetBytes(username + ":" + password));
byte[] byteContent = Encoding.ASCII.GetBytes(Body);
WebRequest webRequest = HttpWebRequest.Create(SandboxRegisterUrl);
webRequest.PreAuthenticate = true;
webRequest.Headers.Add("Authorization", "Basic " + svcCredentials);
webRequest.Method = "POST";
webRequest.ContentType = "application/json";
webRequest.ContentLength = byteContent.Length;
webRequest.UseDefaultCredentials = false;
using (var dataStream = webRequest.GetRequestStream())
{
dataStream.Write(byteContent, 0, byteContent.Length);
dataStream.Close();
}
Co może być nie tak? Wszystko na SO podpowiada mi to co już mam napisane.