REST API Editor

abstract REST Client helps to work easily with REST APIs. With REST Client, you can analyze the response returned by REST API and generate Sahi script. Since Sahi Pro 7.0.0

Launching the REST Client

REST Client can be launched by clicking on the REST Client link from Editor.

REST Request

REST request can be entered by one of the following ways:

Manual Input

Enter the following request parameters: Enter the required fields and click on 'Send Request' button to submit the request and get response.

Import from HAR

Import from network activity in Sahi logs

REST Response

REST Response section displays following information:
  1. Response Status: Displays the response code returned by the server.
  2. Response Header: Displays the response headers returned by the server.
  3. Response Body: Response Body has 3 tabs:
    • Raw: Displays the response body as it is returned.
    • HTML: Displays the parsed HTML if content type returned from server is HTML.
    • TREE: Displays the response body in tree structure if content type returned from server is JSON or XML.

Generate Script

Select the parameters which has to be validated by selecting the checkboxes and click on Generate Sahi Script button. For example: select Response Status, Content Type from Request Headers and place_id from Reponse Body and click on Generate Sahi Script.

Authorization

Basic Auth

Enter the username and password after selecting Basic Auth from dropdown.

OAuth 1.0:

Choose OAuth 1.0 from the Authorization dropdown.
  • Credentials: Select an already saved credential or select Add New from credentials dropdown to add a new credential. Enter a friendly name to save these credentials against. Enter the Consumer Key, Consumer Secret, Token, Token Secret. These details are provided by the API provider.
  • Signature Method: Sahi currently supports HMAC-SHA1 and HMAC-SHA256 signature methods.
  • Version: Enter the version as required by the API under test.
  • Realm: Enter the realm as required by the API under test.
  • OAuth 2.0

    info We recommend you to read the article about OAuth 2 - OAuth 2 Simplified by Aaron Parecki if you're new to OAuth 2.
    References:
    OAuth 2 RFChttps://tools.ietf.org/html/rfc6749
    REST APIhttps://techdocs.ed-fi.org/display/ETKB/REST+API+Guidelines+v2.0+RFC
    1. Sahi's OAuth 2 automation can be accessed from the Authorization drop down as shown in the picture below.
    2. This shows the Access Token field.
    3. If you already have a token you can use that to proceed with the API calls. If you do not have an Access Token, click on Get Access Token ... to open the OAuth 2.0 Consent and Access Token Wizard
    4. Choose one of the options:
      OptionUse
      Access Token without Playback/RecordingChoose this if you are just playing around with the REST API and are not intending to record a script
      Playback of recorded consent scriptChoose this if you already have a recorded consent script which enters the relevant data in a browser window to get the Access Token. You may need this to test different APIs by the same provider
      Record a new consent scriptUse this to record the flow on the browser to get the Access Token. This recorded Sahi script is called the consent script
      Using Refresh TokenUse this option if you have a refresh token
    5. Select the Record a new consent script option from the wizard
    6. Give the consent script a name.
    7. Once you click on Proceed, a new browser window will be opened and you will be prompted for authorization information.
    8. You will be redirected to the Login page provided by the authorization endpoint where you have to provide the username, password and permissions to allow access to the user's resources
    9. You will be now prompted with Access Token Request Input form where the Authorization code will be prefilled. Fill rest of the details and click on Get Access Token
    10. After the access token request is successful, the Access Token field in the REST Client UI will be updated
    11. Click on the Send Request button. The Service Endpoint will respond with the API result