I see a response returned from the web service, but the preview in REST Source does not show any data.
CozyRoc Rest Source Component allow you to Read data from REST
API. The developer can quickly extract response data from the desired endpoint using
HTTP Method (GET, POST) and Output into columns data in preview tab. In this article, we will walk
through some examples that will include defining of Fields and Result Extraction using
the Payload received in response from RESTful API. In order to successfully Read data from the desired endpoint URL to the Output columns, We have to define the Fields and Result Extraction Expression using the Payload(contain actual data) received in the response.
If we are able to see the response from the RESTful API on Web Debugger tool such as Fiddler, but CozyRoc Rest Source preview doesn't show any data in Output column even after the Fields are defined correctly, then most probably the Result Extraction expression need to be defined correctly or it hasn't been included at all.
The below mentioned examples will give you a basic concept about how to setup your Fields and Result Extraction expression, so that the preview tab outputs the desired columns of data.
Example 1
The below screen shots describe what payload to look for when generating fields and what will be the correct Result Extraction expression?
Highlighted desired payload received from REST API response
| Define Fields for the properties Highlighted Yellow in screen shot 1.0
| Define Result Extraction based on the payload Highlighted Yellow in screen shot 1.0 which is Result Array that contains multiple JSON objects with same property names
|
Screen Shot 1.0 | Screen Shot 1.1 | Screen Shot 1.2
|
- Screen Shot 1.0 Contains the response from the REST API which is a Result Array containing multiple JSON objects. The evaluated Result Extraction expression will be {{= response.Results }}. Since the response brought back multiple JSON object therefore the expression doesn't need to be enclosed in Square Brackets [ ]
- Screen Shot 1.1 Contains fields created from the properties highlighted yellow in Screen Shot 1.0.
- Screen Shot 1.2 Contains Result Expression highlighted yellow which is evaluated from the JSON Payload received in the response.
Example 2
The below screen shots describe what payload to look for when generating fields and what will be the correct Result Extraction expression?
- Screen Shot 2.0 Contains the response from the REST API which is a JSON Object. The evaluated Result Extraction expression will be {{= [response] }}, since the response brought back a single JSON object, and therefore the expression needs to be enclosed in Square Brackets [ ]
- Screen Shot 2.1 Contains fields created from the properties highlighted yellow in Screen Shot 2.0
- Screen Shot 2.2 Contains Result Expression highlighted yellow which is evaluated from the JSON Payload received in the response.