var url = "http://domain.herokuapp.com/api/createuser";
var item = new { username = "kasunrt1", email = "[email protected]", password = "3333", tele = "123456789" };
var uri = new Uri(url);
var json = JsonConvert.SerializeObject(item);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var client = new HttpClient();
var result = await client.PostAsync(url, content);
該服務是向上&運行。它適用於瀏覽器&郵差,當我手動執行下面的API字符串。HttpClient的PostAsync失敗上Xamarin.Forms(的StatusCode:404)
http://domain.herokuapp.com/api/createuser/nameTest/[email protected]/346gf4/123456789
即使下面的代碼工作。
var result = await client.PostAsync("http://domain.herokuapp.com/api/createuser/nameTest/[email protected]/346gf4/123456789", null);
結果是404 {的StatusCode:404,ReasonPhrase: '未找到',版本:1.1,內容:System.Net.Http.StreamContent,集管: { 服務器:牛仔 連接:保活 X-已啓動方式:快速 X-Content-Type的選項:nosniff 日期:週五年,2016年11月25日6時27分06秒GMT 途經:1.1 vegur 內容類型:文本/ HTML;字符集= UTF-8 的Content-Length:28 }}
的Heroku僅接收下面的請求。 2016-11-25T06:31:27.827923 + 00:00 heroku [router]:at = info method = POST path =「/ api/createuser」host = domain.herokuapp.com request_id = 1cb51340-05a5-4503- acb5-9e3b45cdf393 FWD = 「61.245.163.5」 DYNO = web.1連接= 1ms的服務= 71個毫秒狀態= 404個字節= 226
我似乎無法找到什麼是錯在這裏。任何幫助將不勝感激。 謝謝!
不能重現。我在問題 –