Без данных запросы отправляются корректно. Такой же curl-запрос отпавлял при помощи языка php - всё корректно работает. На клиенте идет обычный post-запрос.
[WebMethod]
public static string AuthCaptureBlueSnap()
{
string amount = "10.00";
string currency = "USD";
string token = "my_token";
string url = "https://sandbox.bluesnap.com/services/2/transactions";
string data = "{\"cardTransactionType\":\"AUTH_CAPTURE\", \"amount\":" + amount + ", \"currency\":" + currency + ", \"pfToken\":" + token + "}";
string userName = "user_name";
string password = "passowrd";
string usernamePassword = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{userName}:{password}"));
try
{
WebRequest myReq = WebRequest.Create(url);
myReq.Method = "POST";
myReq.ContentType = "application/json";
myReq.ContentLength = data.Length;
myReq.Headers.Add("Authorization", "Basic " + usernamePassword);
UTF8Encoding enc = new UTF8Encoding();
using (Stream ds = myReq.GetRequestStream())
{
ds.Write(enc.GetBytes(data), 0, data.Length);
}
WebResponse wr = myReq.GetResponse();
Stream receiveStream = wr.GetResponseStream();
StreamReader reader = new StreamReader(receiveStream, Encoding.UTF8);
string content = reader.ReadToEnd();
WebHeaderCollection key = wr.Headers;
Dictionary<string, string> response = new Dictionary<string, string>();
for (int i = 0; i < key.Count; ++i)
{
string header = key.GetKey(i);
string value = key.Get(header);
response.Add(header, value);
}
return JsonConvert.SerializeObject(response);
}
catch (WebException ex)
{
WebExceptionStatus status = ex.Status;
WebResponse message = ex.Response;
HttpWebResponse httpResponse = (HttpWebResponse)ex.Response;
Dictionary<int, string> response = new Dictionary<int, string>();
response.Add((int)httpResponse.StatusCode, httpResponse.StatusDescription);
return JsonConvert.SerializeObject(status);
}
}