webCOMAND

Get Web Service

Retrieve objects and their field values in JSON and other formats.

Request

  • query: <OID> | "<UUID>" | "<cPath>" | "<cQL>" | [] – A cPath or cQL query or array of queries that identify the object(s) to retrieve.
  • format: "auto" (default) | "<mime-type>" – Optional format to use for the response.  If exactly one field is specified in the query and a MIME type other than those listed below is specified, the object field value will be converted to the specified format when possible, otherwise an error is returned.  If exactly one field is not specified in the query, only the types listed below are allowed, otherwise an error is returned.
    • auto – If exactly one field is specified in the query, the MIME type will attempt to be determined and used when possible, falling back to application/octet-stream.  Otherwise, 'application/json' will be used.
    • application/json – Encode response in JSON, as described in the Response section below.
    • text/csv – Encode response in CSV format, where each selected field is a column.
    • application/bson – Encode response in BSON, as described in the Response section below.
    • applicaiton/xml – Encode response in XML, as described in COMAND Repository XML.
  • responseMIMEType: "<mime-type>" – Optional MIME type can be specified to include a specific MIME Type in the response Content-Type header, even if the value is not of that MIME type.  No format conversion will be attempted.
  • binaryFormat: "url" (default) | "string" | "base64" – Determines how binary field values will be returned in JSON.
    • url – A string that can be used to make a subsequent Get service request to retreive the value. This is a convenient and efficient way to return image or file data as URLs that can be included in HTML (ie. src and href attributes). A web browser can then make the subsequent requests for image or file values.
    • string – A string that may contain JavaScript string escape codes for non-ascii characters. For example, the string "\u0227" represents the UTF8 text ȧ. This format is automatically decoded by JavaScript, but is not very space efficient (1 to 3 times the size of the raw binary data).
    • base64 – A string containing the base64 encoded value. This format must be decoded
  • asTask: false (default) | true – Perform the request as a task and respond immediately with the task OID and UUID. This is useful for requests that may take time to process, such as certain format conversions. Use the Get service to monitor progress and retrieve results.
  • revision: "active" (default) | "draft" | "working" | <ID> | "<timestamp>" – The revision ID, or timestamp to use to find the closest revision to use to query the database. The revision will determine what object versions to query against based on a point in time.
  • processCScript: true | 1 | 0 - Process cTemplate fields before returning their values.
  • processPublication: <Identifier> | <OID> | "<UUID>" | "<cPath>" | "<cQL>" | true – The Identifier, or an OID, UUID, cPath or cQL query that resolves to a Publication.  If a Publication is resolved, any selected cTemplate fields will be processed in the context of the Publication, processing #LINK(), #OUTPUT() and other cTemplate directives accordingly.  If true is specified, any selected cTemplate fields will be processed without a Publication context, which means that #LINK() and #OUTPUT directives will be ignored (pass through).
  • help: 1 – Include information about the Get web service and it's parameters in JSON format.
  • session: "<session>" – Optional Login session. If it is not specified, the cookie will be checked for the session instead.
  • token: "<token>" – Optional User Token.  If it is not specified, the cookie will be checked for the token instead.

Response

The type of response depends on the requested fields and format (see query and format above).

JSON Objects

When multiple objects and/or fields are requested, the following property is included, along with the Common Response Properties.

  • contents: [{}, {}, ...] – Array of one or more objects in the order they were requested (OID requests first, followed by UUID requests), where each object has a property for each requested field. If no fields were specified, all fields for each object are included. Each field value may be:
    • Data - If the object field is a Data Type field, the value will be returned in the corresponding JavaScript format, which is typically a number or string. Data Type fields that can contain binary data, such as File or Image fields will have a string value that contain a Get service URL, which can be used to request the data. The request can optionally specify a binaryFormat to retreive the actual data encoded in a string.
    • Object(s) - If the object field is a Content Type field, the value will be returned as an object or array of objects in the same format as the objects in the content property array. If the field is a list field, an array of objects is returned. Otherwise a single object is returned. If corresponding sub-fields were not specified in the request, only the OID field is included, which can be used to make subsequent Get serivce requests to obtain additional field values.

Single Object Request Example

$.ajax({
	url: 'https://<account>.webcomand.com/ws/get',
	data: {
		query: "123{SELECT UUID, Type.Identifier}"
	},
	success: function(data) {
		var object = data.contents[0];
		alert(
			'UUID: ' + object.UUID + '\n' +
			'Type: ' + object.Type.Identifier
		);
	},
	error: function(jqXHR, textStatus, errorThrown) {
		alert(textStatus + ': ' + errorThrown);
	}
});

Multiple Object Request Example

$.ajax({
	url: 'https://<account>.webcomand.com/ws/get',
	data: {
		query: [123, 456, '640efc32-1dbd-1e11-7b76-35357616a88b']
	},
	success: function(data) {
		for(var i = 0; i < data.contents.length; i++) {
			var object = data.contents[i];
			alert(
				'Object ' + (i + 1) + '\n' +
				'OID: ' + object.OID + '\n' +
				'UUID: ' + object.UUID + '\n' +
				'Type: ' + object.Type.Identifier
			);
		}
	},
	error: function(jqXHR, textStatus, errorThrown) {
		alert(textStatus + ': ' + errorThrown);
	}
});

Binary Data

When a single object and field is selected by the query or the format is specified, the response is binary data with the corresponding MIME type in the Content-Type header.

Binary Field Request Example

<img src="https://<account>.webcomand.com/ws/get?token=<token>&query=/System/[:ContentType]Authorization{SELECT Icon}" />