Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Create server logic in the Set up workspace in design studio. Each server logic record represents a distinct server API that you can invoke from the client with supported HTTP verbs.
Steps to create server logic
- Sign into Power Pages.
- Select site + Edit.
- Navigate to the Set up workspace, then select Server logic (preview).
- Select +New server logic.
- Enter name for the server logic. This name is used in API as resource identifier while constructing the server logic API.
- Select +Add roles to assign appropriate web role.
- Select 3 dots (…) next to name and select Edit code.
- Select Open Visual Studio Code to author the custom logic.
Call server logic from client script
Note
Each request to server logic request should include Cross-Site Request Forgery (CSRF) token. In general, shell.safeAjax method wraps the CSRF token. Learn more about how to construct requests in CSRF wrapper AJAX function.
Example: calling HTTP GET
shell.safeAjax({
type: "GET",
url: "/_api/serverlogics/serverlogicname?id=1",
contentType: "application/json",
success: function (res) {
console.log(res);
}
});
Example: calling HTTP POST
shell.safeAjax({
type: "POST",
url: "/_api/serverlogics/serverlogicname",
contentType: "application/json",
data: JSON.stringify({
"name": "Sample name"
}),
success: function (res) {
console.log("res");
}
});
Example: calling HTTP PUT
shell.safeAjax({
type: "PUT",
url: "/_api/serverlogics/serverlogicname",
contentType: "application/json",
data: JSON.stringify({
"name": "Sample name"
}),
success: function (res) {
console.log("res");
}
});
Example: calling HTTP PATCH
shell.safeAjax({
type: "PATCH",
url: "/_api/serverlogics/serverlogicname",
contentType: "application/json",
data: JSON.stringify({
"name": "Sample name"
}),
success: function (res) {
console.log("res");
}
});
Example: calling HTTP DELETE
shell.safeAjax({
type: "DELETE",
url: "/_api/serverlogics/serverlogicname?id=1",
contentType: "application/json"
success: function (res) {
console.log("res");
}
});
Example: Response
{
"RequestId": "811b363e-36d2-4213-9f44-a73bf7550ce8",
"Success": true,
"Data": "Sample data",
"ExecutionTime": 9256.331,
"ServerLogicName": "serverlogicname",
"Error": null
}
Next step
Related information
Server logic overview
How to interact with Dataverse tables using server logic