Recent Posts

    Authors

    Published

    Tag Cloud

    How to check your ReST service returns expected format/values?

    Use sanity checks to test your ReST services and variables

     You can view all the ReST services and their details via CMS/RESTful API

     

    You can also try or edit a ReST service here 

     To set up a sanity check for a ReST service, click the "Edit" button, and go to "Sanity" tab

    Click "Add" button to add a new sanity check or click one check to edit it.

    Enter the additional path, and all parameters, the results section will show you the response status and response JSON

     

    Click "Add" button in the "Checks" section to add one check for this sanity check. Enter the JSON Path you'd like to check and RegEx pattern for expected value, the results will be shown in the Results section.

    Valid JSON Path could be:

    • $ - shows the whole JSON Object or JSON Array
    • $[0] - shows the first element in the root JSON Array
    • $.results[0].folderid.path - shows the folderid.path of the first element in the results attribute

     

    You also could add sanity check for a rest variable. Go to Variables tab in the ReST Definition data entry screen 

     

    Click a variable to open the variable data entry screen 

     

     You may have some logic to parse the variable values in the Parse tab. The screen shot shows a parser that adds double quotes for each country code

    You can add variable sanity checks in the Sanity tab

     Enter test value, and expected response status code and RegEx pattern for the expected values to test