OutSystems Forge 日本語データベース

How to Expose a REST API

※Forge全件データの日本語検索サービスをご利用になりたい場合は、こちらまでお問合せください。

Forge英文サイト

2015-05-04 1.0.0 OutSystems TechComm 9.0.1.3 All All How-tos
レコードをリスト作成、更新、および削除するメソッドを持つ、公開されたREST APIのサンプル。 また、要求されたメソッドの実行に問題が発生した場合に、カスタムエラーメッセージを送信する方法を示します。 REST APIは基本認証を使用します。
REST APIを使用すると、HTTP経由でアプリケーションのデータと機能を公開し、他のシステムで使用することができます。 このプロジェクトの各REST APIメソッドは、REST APIを公開する方法の1つまたは2つの使用例を示しています。方法を確認してください: データを提供するメソッドを公開する - このメソッドでは、 'HTTPメソッド'プロパティをGETに設定します。 - 連絡先リストを出力パラメータとして追加します。 - パラメータの 'Send In'プロパティで要求の出力の配置を設定します。 RESTを使用してデータを公開する方法について詳しくは、こちらをご覧ください。 データを作成する方法を公開する - このメソッドでは、 'HTTP Method'プロパティをPOSTに設定します。 - 入力パラメータとして連絡先を追加し、出力パラメータとして連絡先識別子を追加します。 - 入力パラメータが 'Receive In'プロパティで受信された場所を設定します。 - 出力パラメータが 'Send In'プロパティで送信される場所を設定します。 RESTを使用してメソッドを公開してデータを作成する方法の詳細をご覧ください。 データを更新するメソッドを公開する - このメソッドでは、 'HTTPメソッド'プロパティをPUTに設定します。 - 入力パラメータとして連絡先を追加します。 - パラメータの 'Receive In'プロパティで要求の入力の配置を設定します。 メソッドを公開してRESTを使用してデータを更新する方法について詳しくは、こちらをご覧ください。 データを削除する方法やエラーを発生させる方法を公開する - このメソッドでは、 'HTTPメソッド'プロパティをDELETEに設定します。 - 連絡先識別子を入力パラメータとして追加します。 - パラメータの 'Receive In'プロパティでリクエスト内の入力の配置を設定します。 - メソッドロジックで、このレコードの削除に問題がある場合は、Raise Error要素を使用してカスタムエラーを発生させます。 メソッドを公開してRESTを使用してデータを削除する方法について詳しくは、こちらをご覧ください。 カスタムエラーメッセージを追加する方法について詳しくは、こちらをご覧ください。 公開されたREST APIに基本認証を追加する アクションは、UsersモジュールのUser_Loginアクションを呼び出します。 認証が成功すると、直ちに呼び出されたREST APIメソッドが実行されます。 それ以外の場合は、例外が発生し、要求がアボートされ、応答によってセキュリティエラーが返されます。。 公開されたREST APIに基本認証を追加する方法の詳細をご覧ください。

[Overview]
Sample of an exposed REST API with methods to list, create, update, and delete records. It also demonstrates how to send a custom error message if something goes wrong in the execution of the requested method. The REST API uses Basic authentication.
[Detail]
REST APIs allow you to expose data and functionality of your application over HTTP to be used by other systems. Each REST API method of this project illustrates one or two use cases of how you can use expose REST APIs. Check how to: Expose a method to provide data - In the method, set the 'HTTP method' property to GET; - Add a Contact List as output parameter; - Set the placement of the output in the request at the 'Send In' property of the parameter. Learn more about how to expose data using REST. Expose a method to create data - In the method, set the 'HTTP Method' property to POST; - Add a Contact as input parameter, and a Contact Identifier as output parameter; - Set where the input parameter is received in its 'Receive In' property; - Set where the output parameter is sent in its 'Send In' property. Learn more about how to expose a method to create data using REST. Expose a method to update data - In the method, set the 'HTTP method' property to PUT; - Add a Contact as input parameter; - Set the placement of the input in the request at the 'Receive In' property of the parameter. Learn more about how to expose a method to update data using REST. Expose a method to delete data or raise an error - In the method, set the 'HTTP method' property to DELETE; - Add a Contact Identifier as input parameter; - Set the placement of the input in the request at the 'Receive In' property of the parameter; - In the method logic, raise a custom error using the Raise Error element if there is any problem with deleting this record. Learn more about how to expose a method to delete data using REST. Learn more about how to add a custom error message. Add Basic authentication to an exposed REST API The action calls the User_Login action of the Users module. If the authentication succeeds, the invoked REST API method is executed immediately after. Otherwise, an exception is raised, the request is aborted, and the response returns a security error. Learn more about how to add Basic authentication to an exposed REST API.
戻る