Operations on CTERA API Objects > Invoking Extended Methods
Invoking Extended Methods
Some CTERA API objects expose extended methods, which can be invoked to perform operations on the object.
Extend a CTERA Portal API object.
API
admin/api/object
URI
{BASE_URL}/object
HTTP Method
POST
Request Content-Type
application/xml
Request Body
<obj>
  <att id="name">
    <val>method_name</val>
  </att>
  <att id="param">
    {Request_parameters_in_XML_format}
  </att>
</obj>
Expected Response status
200 OK
Java Example
// invoke a method on the specified object URL
private static String invokeMethod(HttpClient client, String url, String methodName, String params) throws Exception {
  String requestBody = prepareRequest(methodName, params);
  StringRequestEntity request = new StringRequestEntity(requestBody,                                                       "text/xml", "UTF-8");
  PostMethod method = new PostMethod(url);
  postMethod.setRequestEntity(request);
  int statusCode = client.executeMethod(method);
  String response = new String(method.getResponseBody());
  if (statusCode != HttpServletResponse.SC_OK)
    throw new Exception(response);
  return response;
}
// wrap the method name and parameters in an XML envelope
private static String prepareRequest(String methodName, String params) throws Exception {
  StringBuilder builder = new StringBuilder();
  builder.append("<obj><att id=\"name\"><val>");
  builder.append(methodName);
  builder.append("</val></att><att id=\"param\">");
  builder.append(params);
  builder.append("</att></obj>");
  return builder.toString();
}