Pular para o conteúdo principal

Execute API

Description

This method can be used inside any workspace. To call the API service and execute a Restful operation.

Method(s)

public executeAPI(
method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH",
relativePath: string,
params?: { [name: string]: string },
body?: object,
showToast = true,
headers: { [name: string]: string } = {},
setContentTypeHeader = true,
setProfileRequest = true,
useCache = false
): Promise<any> {
return this.executeApiService.executeAPI(
Apis.apiV2,
method,
relativePath,
params,
body,
showToast,
headers,
setContentTypeHeader,
setProfileRequest,
useCache
);
}
ParameterTypeRequiredDefaultsDescription
methodStringtrueSet the type of request
relativePathStringtrueUrl request
paramsStringfalseParameters that are intended to be passed in the request
bodyStringfalseThe content to replace with
showToastStringfalsetrueTo return a toast related to the request when error occurs
headersStringfalseemptyMeta-data associated with the API request and response
setContentTypeHeaderStringfalsetrueIf it's set to true it will append 'Content-Type' to the header with the value 'application-json'
setProfileRequestStringfalsetrueIf it's set to true it will append 'x-sw-profilerequest' to the header with the value 'true'
useCacheStringfalsefalseIf it's set to true it will cache the request

Basic Usage

SW.executeAPI("GET", "documentBriefs", {
documentId: "d8615b0f-4b52-4360-8f61-62c62bcb5463",
});

Example

img-box-shadow