Use WebData sources in reports.
Reference → Modules → Reports → UI → Forms Editor | Forms | Monitor | WebData | WebData Editor
Reports WebData (Reference) onfiguration objects facilitate data exchange between applications using JSON, XML, HTML, or text formats, enabling integration with web services and RESTful APIs. WebData objects provide:
WebData enables both consuming external APIs and exposing solution data to other systems.
| Property | Description | Required |
|---|---|---|
| Name | Unique WebData identifier | Yes |
| Encoding | Data format (JSON/XML/HTML/Text) | Yes |
| DefaultURL | Default API endpoint | No |
| Authorization | Authentication method | No |
| Headers | Request/response metadata | No |
| SaveFileName | Local file path for saving | No |
| Padding | Whitespace handling | No |
| EditSecurity | Permission groups | No |
| Length | Data size in bytes | Auto |
| Description | Documentation text | No |
No credentials sent:
Authorization: NoAuthToken-based authentication:
Authorization: Bearer <token>
Headers: {"Authorization": "Bearer {{Tag.APIToken}}"}Username/password authentication:
Authorization: Basic
Username: {{Tag.Username}}
Password: {{Tag.Password}}Define custom authentication:
Headers: {
"X-API-Key": "{{Tag.APIKey}}",
"X-Client-ID": "{{Tag.ClientID}}"
}Execute data retrieval:
// Async GET request string response = await @Report.WebData.MyAPI.GetRequestAsync(); // Store in tag @Tag.APIResponse = response; // Access via DocumentClient string data = @Report.WebData.MyAPI.DocumentClient;
Send data to API:
// Execute POST await @Report.WebData.MyAPI.PostRequestAsync(); // Response stored in specified tag string result = @Tag.PostResult;
In POST requests, the response from the server is not returned directly by the method call. Instead, the response binding is configured declaratively in Reports / WebData, using the Headers column. There, you map the built-in ResponseTag property to any Text-type tag in your solution using the standard tag reference syntax, you can see the example in the table below. Once that mapping is in place, executing the request with await @Report.WebData.MyAPI.PostRequestAsync() will automatically store the server's response body into the linked tag.
| Key | TagName |
|---|---|
| ResponseTag | MyResponseTag |
ResponseTag is a default name to receive the response.
MyResponseTag is any Text-type tag in your solution.
Define request structure and bind tags:
{
"timestamp": "{{Info.Date}}",
"values": {
"temperature": {{Tag.TankFarm/Tank1/Temp}},
"pressure": {{Tag.TankFarm/Tank1/Pressure}},
"status": "{{Tag.Equipment/Status}}"
}
}
<data>
<timestamp>{{Info.Date}}</timestamp>
<temperature>{{Tag.TankFarm/Tank1/Temp}}</temperature>
<pressure>{{Tag.TankFarm/Tank1/Pressure}}</pressure>
</data>
Method 1: Direct Assignment
@Tag.JSONResponse = await @Report.WebData.API.GetRequestAsync();
Method 2: DocumentClient Property
await @Report.WebData.API.GetRequestAsync(); string data = @Report.WebData.API.DocumentClient;
Method 3: Tag Binding in Editor Map response fields to tags in WebData Editor
Common headers:
{
"Content-Type": "application/json",
"Accept": "application/json",
"ResponseTag": "Tag.APIResult",
"X-Request-ID": "{{Tag.RequestID}}"
}
// Configure SaveFileName @Report.WebData.API.SaveFileName = @"C:\Data\response.json"; // Execute and save await @Report.WebData.API.GetRequestAsync(); @Report.WebData.API.Save();
C:\Data\API_{{Tag.Date}}_{{Tag.Time}}.json| Option | Effect | Use Case |
|---|---|---|
| Compact | No extra whitespace | Minimal payload |
| PadRight | Space after values | Fixed-width format |
| PadLeft | Space before values | Numeric alignment |
try
{
string response = await @Report.WebData.API.GetRequestAsync();
if (!string.IsNullOrEmpty(response))
{
@Tag.Status = "Success";
ProcessResponse(response);
}
}
catch (Exception ex)
{
@Tag.ErrorMessage = ex.Message;
@Tag.Status = "Failed";
}
@Report.WebData.Weather.DefaultURL =
"https://api.weather.com/v1/location/{{Tag.City}}";
string weather = await @Report.WebData.Weather.GetRequestAsync();
// Configure POST body with sensor data await @Report.WebData.IoT.PostRequestAsync();
// Get external data string data = await @Report.WebData.External.GetRequestAsync(); // Parse and update local database UpdateDatabase(data);
Connection failed:
Invalid response:
Authentication errors:
Performance issues: