Makes HTTP requests through the platform's window.
The requestPlatformData capability provides a means of making HTTP requests through APIs connected by the underlying platform. This allows a platform to provide shared authentication, caching, and session management across all Tecton extensions making requests to a supported platform API.
Requests can be made either by specifying direct URL routes or by using a dataType identifier which the platform can map to an appropriate endpoint. The API supports standard HTTP methods, request bodies, query parameters, and FormData uploads when available.
requestPlatformData returns a promise containing the response body or throws an error for non-200 series responses.
tecton.sources.requestPlatformData(requestOptions: PlatformRequestBody): Promise<XMLHttpRequest>;export type PlatformRequestBody = PlatformDataRequest | PlatformRouteRequest;export interface PlatformRouteRequest {
route: string;
method?: 'POST' | 'PUT' | 'DELETE' | 'GET';
body?: string | FormData;
}export interface PlatformDataRequest {
dataType: string;
dataId?: string;
params?: Record<string, string>;
method?: 'POST' | 'PUT' | 'DELETE' | 'GET';
body?: string | FormData;
}Making a POST request to create a new user via direct route.
tecton.sources.requestPlatformData({
route: '/user',
method: 'POST',
body: JSON.stringify({
name: "Tecton",
email: "tecton@q2.com"
})
}).then((xhr) => {
// Do something with response
}).catch((xhr) => {
// Fires for non 200 series responses
});Making a GET request to fetch account data via dataType.
tecton.sources.requestPlatformData({
dataType: 'Account',
dataId: '1234',
method: 'GET',
}).then((xhr) => {
// Do something with response
}).catch((xhr) => {
// Fires for non 200 series responses
});requestOptions.routerequestOptions.dataTyperequestOptions.dataIdrequestOptions.paramsrequestOptions.methodrequestOptions.body