0
Postman
とx-www-from-urlencoded
と基本認証ですべて正常に動作します。今私の手を汚してみると、私はちょうど郵便銃に何もない状態コード200を得て、ログは記録されません。maingunはOKで返信しますが、何も起こりません。
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("https://api.mailgun.net/v3");
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("api", "key-withheld-till-a-verdict-has-passed");
var msg = new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>("from",
$"Excited User <[email protected]>"),
new KeyValuePair<string, string>("to","[email protected]"),
new KeyValuePair<string, string>("subject", "Test Please Do Not Reply"),
new KeyValuePair<string, string>("text","Thanks for borrowing me your inbox")
};
var request = new HttpRequestMessage(HttpMethod.Post,
"sandboxSOMEGUIDHERE.mailgun.org/messages");
request.Content = new FormUrlEncodedContent(msg);
var response = await client.SendAsync(request);
// I get 200 status code
var result = await response.Content.ReadAsStringAsync();
//I get result = "Mailgun Magnificent API"
}
これは正しい応答のようには思われません。正しいURL/APIエンドポイントを使用していますか? – FrankerZ
私は 'Postman'でテストし、すべてが完璧に機能しました。 –
[こちら](http://stackoverflow.com/questions/18924996/logging-request-response-messages-when-using-httpclient)をご覧になり、リクエストを記録してください。郵便配達要求とc#要求の違いを探します。 – FrankerZ