API version 1

- ‐

post

指定先のサーバへ非同期POSTリクエストを開始します。

メソッドは通信を開始した後に終了を待たずに直ちに終了します。

リクエストに含めるFORMパラメータは、HttpRequest.addParam メソッドで設定します。

HTTPレイヤーの実行結果は、 SessionEnd イベントで返されるstatusの値で確認します。

呼出形式一覧

呼出形式

説明

void post(CRS::Common::Net::HttpRequest req)

指定先のサーバへ非同期POSTリクエストを開始します。

戻り値一覧

戻り値

説明

void

なし

引数一覧

引数

説明

req

通信リクエストを示すHttpRequestオブジェクトを指定します。

createRequest メソッドで作成します。

例外

識別子

説明

SYS-50:1

通信エラー

SYS-50:2

URLが不正です

SYS-50:3

リクエストがエラー終了しました

CRS::Common::Core-1:1

不正な値です

CRS::Common::Net::HttpSession-1:2

指定のhttpRequestはコネクション先が異なります

CRS::Common::Net::HttpAsyncSession-1:2

指定のIDはすでに使用されています

関連項目

createRequestget メソッド

SessionEnd イベント



使用例 CRSダウンロード

Form HTTPAsync2 {
   X = 0;
   Y = 0;
   width = 745;
   height = 441;
   reference ref;

   EditBox edtResult {
           x = 31;
           y = 127;
           Width = 369;
           Height = 123;
   }
   httpAsyncSession asyncSession {
           Function OnSessionEnd( e ) {
                   ^.edtResult += "ID=" + e.id + " / ステータスコード=" + Str(e.status) +
                           " / message=" + e.message + "\n/ body=" + e.response.body + "\n";
           }
   }

   Label Label3 {
           x = 31;
           y = 28;
           width = 351;
           height = 16;
           Value = "非同期通信機能(create後にpostを押します。1度のみ)";
   }

   TextBox txtURL1 {
           x = 32;
           y = 49;
           Width = 292;
           Height = 24;
           Value = "https://postman-echo.com/post";
   }

   Button Btn_CreateRequest {
           x = 31;
           y = 84;
           Width = 162;
           Height = 30;
           Title = "CreateRequest(ID, URL)";
           Function OnTouch( e ) {
                   try {
                           ^.ref.value = ^.asyncSession.createRequest("post", ^.txtURL1.Value);
                           ^.Btn_POST.Active = true;
                   }
                   catch(e) {
                           MessageBox("Message=" + str(e.Message) + "\nCategory=" + str(e.Category) + "\nCode="+ str(e.Code)  + "\nSubCode=" + str(e.subCode));
                   }
           }
   }

   Button Btn_POST {
           x = 230;
           y = 85;
           Width = 88;
           Height = 30;
           Title = "POST";
           Function OnTouch( e ) {
                   try{
                           var res = ^.asyncSession.post(^.ref.value);
                           /* Active = false; */
                   } catch(e){
                           MessageBox("Message=" + str(e.Message) + "\nCategory=" + str(e.Category) + "\nCode="+ str(e.Code)  + "\nSubCode=" + str(e.subCode));
                   }
           }
   }
}