You can make calls to a Kepler service using any standard REST or HTTP client, because all Kepler APIs are exposed over the HTTP protocol. By default, Kepler service calls use the POST method, but other HTTP methods are available. For more information, see HTTP headers, verbs, and related information.
Complete these steps to a call to an endpoint:
- Set the required headers for a Kepler service call:
- X-Kepler-Version header - defines the wire protocol version for the Kepler call and defaults to the current standard.
- X-CSRF-header - prevents cross-site request forgery (CSRF) attacks in the browser. You must set this header, but you can assign any value to it. In general, the header value is set to a dash(-). For more information, see X-CSRF-Header.
Don't leave this header value blank. Some browsers remove empty headers.
The Kepler framework returns a 404 status code when the X-CSRF-header isn't submitted. If unexpected 404 status code is returned, make sure that you have included the proper header.
- Content-Type header - indicates the content-type of the request made to the Kepler service. This header must be set to application/json because the Kepler framework only uses JSON payloads.
- Make a call using the URL generated through Kepler framework. It has the following general format:
Copy1
<host>/Relativity.REST/api/{ModuleName}/{InterfaceName}/{MethodName}
This basic URL template includes the following tokens for the endpoints generated by the Kepler framework:
- {ModuleName} - the name of the module that the interface for your service is associated with. See Service module.
- {InterfaceName} - the name of the interface or contract exposed for your service. See Service contract.
- {MethodName} - the name of the method on your interface used for the functionality that you want to access.
For detailed route information, see Kepler service structure and components
- Build a JSON payload. When you call a Kepler service, your arguments are sent in the body of a POST call. The arguments are structured as a JSON object that matches the parameters of your service.
For example, you have a service call with the following signature:
Copy1
Task DoStuffAsync(int a, int b, string name);
Your JSON payload would have the following format:
Copy1
2
3
4
5
{
"a":42,
"b":99,
"name":"Ziggy"
}
Use valid JSON with the appropriate data types in the payload. The following formatting rules apply to certain data types:
- Enumeration - represented via their .NET string name instead of an integer value.
- DateTime - represented as a string using ISO8601 format, such as 2009-02-15T00:00:00Z.
- GUID - represented represented as a string with 32 digits separated by hyphens, such as 00000000-0000-0000-0000-000000000000.
- Empty argument - leave the POST body empty.
- Progress and cancellation - use GUIDs at the JSON layer.