using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Http;
using System.Net;
using System.Net.Http.Headers;
using System.Text.Json;
namespace TestHTTP
{
class TestingWindcaveSDK
{
private static readonly HttpClient client = new HttpClient();
static async Task Main()
{
await PostRequest();
}
async static Task PostRequest()
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", !!!!!!SECRET!!!!!!);
var values = new Dictionary<string, string>
{
{ "type", "auth" },
{ "amount", "10.00" },
{ "currency", "NZD" }
};
string body = JsonSerializer.Serialize(values);
var content = new StringContent(body, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://dev.windcave.com/api/v1/sessions/", content);
var responseString = await response.Content.ReadAsStringAsync();
Console.WriteLine("hello!");
Console.WriteLine(response);
Console.WriteLine(responseString);
}
}
}
That '!!!!!SECRET!!!!' is just the key of the header when you make a request in postman. It's not just the API Key, it's the encoded value so you have to go into the key tab (i think? I'll have to look into it again later)
Here, I'm using Windcave SDK for Windcave REST API being developed by one of my coworker (from the same class).
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Http;
using System.Net;
using System.Net.Http.Headers;
using System.Text.Json;
using Windcave.Payments.SDK;
namespace TestHTTP
{
class TestingWindcaveSDK
{
private static readonly Windcave.Payments.SDK.HttpClient client = new Windcave.Payments.SDK.HttpClient();
static void Main()
{
SessionRequest session = new SessionRequest()
{
TransactionType = TransactionType.Auth,
Amount = 10M
};
WindcaveClient wcClient = new WindcaveClient("HajinK", !!!YOUR API KEY!!!)
{
ApiBase = "https://dev.windcave.com/"
};
WindcaveSDK sdk = new WindcaveSDK(wcClient, client);
SessionResponse res = sdk.Create<SessionRequest, SessionResponse>(session);
Console.WriteLine(res.Links[1].HRef);
//await PostRequest();
}
}
}
!!!YOUR API KEY!!! is the actual key for your account