Как интегрировать BPOST API в C#.
Я пытался описанным ниже способом, но получаю ошибку "Неверный URL или ключ API."; account_number и пароль верны. Я думаю, что проблема в postmen-api-key , как его получить?
WebRequest httpWebRequest = WebRequest.Create("https://sandbox-api.postmen.com/v3/shipper-accounts");
string json = "{\"slug\":\"bpost\",\"description\":\"My Shipper Account\",\"timezone\":\"Asia/Hong_Kong\",\"credentials\":{\"account_number\":\"******\",\"passphrase\":\"******\",\"return_instructions\":\"******\"},\"address\":{\"country\":\"USA\",\"contact_name\":\"Sir Foo\",\"phone\":\"2125551234\",\"fax\":\"+1 206-654-3100\",\"email\":\"foo@foo.com\",\"company_name\":\"Foo Store\",\"street1\":\"255 New town\",\"street2\":\"Wow Avenue\",\"city\":\"Beverly Hills\",\"type\":\"business\",\"postal_code\":\"90210\",\"state\":\"CA\",\"street3\":\"Boring part of town\",\"tax_id\":\"911-70-1234\"}}";
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
httpWebRequest.Headers["postmen-api-key"] = "8fc7966b-679b-4a57-911d-c5a663229c9e";
using (StreamWriter streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
streamWriter.Write(json);
streamWriter.Flush();
streamWriter.Close();
}
HttpWebResponse httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (StreamReader streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
string result = streamReader.ReadToEnd();
Console.WriteLine(result);
}