Xamarin: HTTP POSTリクエスト

概要 XamarinでSystem.Net.Http.HttpClientを使用してHTTPのPOSTリクエストを行う。 docs.microsoft.com サンプルコード static readonly HttpClient client = new HttpClient(); private static async Task HttpRequestPostAsync() { Dictionary<string, string> parameters</string,>…

Get a string from other file and use it for the variable in your Windows Batch file

Summary Get a string from other file and use if for the variable in your Windows Batch file. In this example, we'll get application version number string from build.gradle file that used for Android application development. Sample build.gr…

Xamarin: AndroidでHTTPリクエストを行うと"Java.IO.IOException: Cleartext HTTP traffic to XXX not permitted"エラー

概要 Android 9以上を対象したアプリでHTTP通信を行うと発生するエラーの対応方法。 詳細 Androidの"対象Androidバージョン"を9.0(API level 28)以上にした場合、HTTPリクエストを行うと以下のエラーが発生する。 Java.IO.IOException: Cleartext HTTP traff…

Xamarin: iOSでHTTPリクエストを行うと"App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file."エラー

概要 iOS 9以上ではApp Transport Securityの導入により、HTTPリクエストを実行するとエラーが発生する。その対応。 Info.plistの設定変更 <プロジェクト名>.iOS以下にあるInfo.plistを開き、以下の設定を追加する。 NSAppTransportSecurityについては以下を…

Xamarin: エラー"System.NotSupportedException: Encoding 932 data could not be found. Make sure you have correct international codeset assembly installed and enabled."

概要 System.Net.Http.HttpContent.ReadAsStringAsync()メソッドを使用した際に以下のエラーが発生した場合の対応方法。 System.NotSupportedException: Encoding 932 data could not be found. Make sure you have correct international codeset assembly …

バッチファイル内で別ファイルからバージョン番号を取得して変数として使用する

概要 バッチファイル内で使用する変数として、別ファイル内に書かれているバージョン番号を取得して使用する。 以下ではAndroidアプリ開発で使用するbuild.gradleファイル内からバージョン番号を取得する。 build.gradleファイル 以下のversionName "1.0.0"…

Xamarin: HTTP GETリクエスト

概要 XamarinでSystem.Net.Http.HttpClientを使用してHTTPのGETリクエストを行う。 docs.microsoft.com サンプルコード static readonly HttpClient client = new HttpClient(); // A) async void OnButtonClicked(System.Object sender, System.EventArgs e…