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
我用'郵差'測試過,一切都很完美。 –
看看[這裏](http://stackoverflow.com/questions/18924996/logging-request-response-messages-when-using-httpclient)並記錄你的請求。尋找郵遞員請求和c#請求之間的差異。 – FrankerZ