This repository has been archived by the owner on Aug 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
api request
Ayhan Rashidov edited this page Sep 27, 2021
·
11 revisions
Represents the client HTTP request currently being processed. This API is used for retrieving request data from the xsk HTTP service caller.
- SAP Help
https://help.sap.com/doc/3de842783af24336b6305a3c0223a369/2.0.03/en-US/$.web.WebRequest.html
- Module
- Sample usage:
function getUser(id) {
// retrieve user by id
}
function createUser(data) {
// create user
}
function deleteUser(id) {
// delete user
}
if(/\/?users$/.test($.request.queryPath)) {
const id = $.request.parameters.get("id");
if ($.request.method === $.net.http.PUT) {
if($.request.contentType === "application/json") {
createUser($.request.body);
$.response.setBody(`created user [${ JSON.stringify($.request.body.asString()) }]`);
} else {
$.response.setBody(JSON.stringify({
"error": "Unsupported content type."
}));
}
} else if(id) {
switch($.request.method) {
case $.net.http.GET:
getUser(id);
$.response.setBody(`retrieved user with id ${ id }`);
break;
case $.net.http.DELETE:
deleteUser(id);
$.response.setBody(`deleted user with id [${ id }]`);
break;
default:
$.response.setBody(JSON.stringify({
"error": `Unsupported method [${ $.request.method }]`
}));
}
} else {
$.response.setBody(JSON.stringify({
"error": "Missing required parameter [id]"
}));
}
} else {
$.response.setBody(JSON.stringify({
"error": `Unsupported query path [${ $.request.queryPath }]`
}));
}
- Coverage
Members | Description | Status |
---|---|---|
body | The body of the request. | ✅ |
contentType | The content type of the entity. | ✅ |
cookies | The cookies associated with the entity. | ✅ |
entities | The sub-entities of the entity. | ✅ |
headers | The headers of the entity. | ✅ |
language | Language of the request in IETF (BCP 47) format. | ✅ |
method | The HTTP method of the incoming HTTP request. | ✅ |
parameters | The parameters of the entity. | ✅ |
path | The URL path specified in the request. | ✅ |
queryPath | The URL query path specified in the request. | ✅ |
Methods | Description | Status |
---|---|---|
setBody() | Sets the body of the entity. | ❌ |
- Issues
- Unit Tests
⚠️
- Integration Tests ❌
✅ - Feature implemented and working as supposed.
❌ - Feature not implemented yet.