RestApi

The RestApi plugin lets you reference an Api and return a string or JSON response.  

Parameters are as follows, examples are shown in bold: 

Source  The id of an “api” type Data Source that has been set up in fAdmin.
The uri parameter of the Data Source contains the domain of the API resource
ClientOrdersApi
Resource The api resource required
orders/1023 
QueryString  Optional querystring parameters. These should be given as comma separated IDs, and then the parameter values you require added afterwards. The following example would result in “?option=6&type=small” being passed to the api.
option,type

option=6
type=small
 
Token  Optional bearer token (usually passed via a function which refers to a value in another data group).
This will be passed within a header as “Bearer”.

=RAWVALUE(Token,TokenDataGroup) 
Form  For post method, a JSON dictionary of form values
{“UserId”:”abc123″,”Password”:”je83d!m“} 
Method  get (default) or post 
Root  Optional path to the root of the section required
orderLines[2].product 
AsString  true if a string value is expected or required (saved as column “Response”) 

 

Schema Considerations

In order for a schema to be built (for fDocs to build a tag list or fPanels to show the field), a valid response must be returned from the Api assuming any Placeholders are 0 if they are numeric, or blank if they are string.

For the above example, assuming “orders/#OrderId#” is used in the resource parameter above, and that #OrderId# is a User Entry (in numeric format), then running the Api with orders/0 must return a valid JSON in order for a valid schema to be built.

If this would cause the Api to fail to give a response, then create a new Placeholder in your Data Group that has the format of “Sample” and enter a sample value that would return a valid response for the schema. This new placeholder should have a function entered (for example, =USERENTRY(OrderId) ) that takes the value from the User Entry when the end user requests a report, and use this new placeholder’s Id in the resource parameter above, rather than the Id of the User Entry.

image_pdfimage_print