2016-09-19 80 views
1

我們正試圖從我們的Xamarin Forms項目調用Salesforce restful API。這些調用在iOS應用程序方面工作正常,但Android失敗。Xamarin表單 - Salesforce - TLS 1.1或TLS 1.2。針對Android的POST API調用錯誤

HttpClient authClient = new HttpClient(); 
message = await authClient.PostAsync("url", content); 
string responseString = await message.Content.ReadAsStringAsync(); 

我們在Android的「responseString」變量中收到以下響應。

<tr><td width="100%" height="100%"><div class="content"> 
<h1>**Stronger security is required**</h1><div class="simple"> 
<p>**To access this website, update your web browser or upgrade your operating system to support TLS 1.1 or TLS 1.2.**</p> 
<p>For more information, see 
<a href="https://help.salesforce.com/HTViewSolution?id=000221207&amp;language=en_US" target="_blank">Salesforce disabling TLS 1.0</a>. 
</p> 
</div></div></td></tr> 
</table></body> 
</html> 

我們需要找到一個應該支持iOS,Android和Win 10應用程序的解決方案。我們檢查了iOS,它工作。現在爲了Android而加入並且不工作。對於Windows,我們不檢查。

請幫忙。

回答

0

我還沒有親自去過這個問題,但你可能會給ModernHttpClient一槍。安裝該庫允許您將NativeMessageHandler傳入您的HttpClient。這將使用Android上的本機實現,這將允許使用Xamarin Forms實現不能實現的額外安全功能。

如果可能,您還應該將Xamarin Forms庫更新爲最新版本。

您的代碼將成爲(我還添加了using,因爲它是很好的做法):

using(HttpClient authClient = new HttpClient(new NativeMessageHandler())) { 
    message = await authClient.PostAsync("url", content); 
    string responseString = await message.Content.ReadAsStringAsync(); 
}