Scripted REST API example - script samples
-
- UpdatedAug 1, 2024
- 4 minutes to read
- Xanadu
- API implementation
These examples demonstrate how to create various resource scripts for a scripted REST API.
Query parameters GET example
This example demonstrates how to get query parameter values from a request.
Path parameters GET example
This example demonstrates how to get path parameter values from a request.
Script include GET example
This example demonstrates how to use a script include to provide a response. By using a script include you can reuse common code and maintain readability in the REST service scripts.
String POST example
This example demonstrates how to parse a POST message with a string body and send a response based on the request.
Binary POST example
This example demonstrates how to parse a POST message with a binary body and send a response based on the request.
Not acceptable error example
This example demonstrates how to respond with a not acceptable error. Use this error type when the request Accept header value is not supported by the web service.
Bad request error example
This example demonstrates how to respond with a bad request error. Use this error type to indicate a mistake in the request syntax.
Conflict error example
This example demonstrates how to respond with a conflict error. Use this error type in the event of multiple conflicting requests, such as multiple updates to the same record.
Not found error example
This example demonstrates how to respond with a not found error. Use this error type if the requested resource does not exist or is unavailable.
Unsupported media type error example
This example demonstrates how to respond with an unsupported media type error. Use this error type to indicate that the Content-Type of the request is unsupported.
Service error example
This example demonstrates how to respond with a generic service error. The ServiceError object allows you to define the status code, message, and error detail. Use a ServiceError if the predefined error types do not meet your needs.
Scripted REST resource script example
Requests
JSON Request | XML Request |
---|---|
Responses
On this page
- Query parameters GET example
- Path parameters GET example
- Script include GET example
- String POST example
- Binary POST example
- Not acceptable error example
- Bad request error example
- Conflict error example
- Not found error example
- Unsupported media type error example
- Service error example
- Scripted REST resource script example
- Requests
- Responses