Invoking APIs‎ > ‎

Use Binary Data

You can store images, icons, pictures, documents, voice, video, and other binary data in Live API Creator using various SQL database datatypes (for example, Binary Large OBjects (BLOBs) and Character Large OBjects (CLOBs)).

For more information about BLOBs and CLOBs, see BLOB, CLOB, Large Strings, Large Binary.


Choose How API Creator Emits Binary Data

The JSON response format can return binary data as either Base64 or Hex. You can choose the encoding scheme for your API project. API Creator attempts to return binary data inline if the size is less than the default inline limit (the default value for the inlinelimit query parameter) and if you have chosen not to force binary data as an object. Base64 string format returns values beginning with 'b64' and Hex values return values beginning with '0x'.

For more information about how to choose the encoding scheme for your API project, how to define the default values for the inlinelimit query parameter, and about how to force binary data as an objectsee API Properties.

Retrieve Data

Use the Demo API project sample application. In the following example, the REST response shows the icon attribute emitted as an object of type Base64. The picture attribute returns a URL instead of a value. When the object length is greater than the default inline limit (the default value for the inlinelimit query parameter), then you can retrieve the /data/ portion of that field using the URL.

For more information:

  • About the Demo API project sample application, see Demo.
  • About how to define the default values for the inlinelimit query parameter, see API Properties.

URI

In the REST Lab, select employee_picture and do a GET:

https://localhost:8080/APIServer/rest/el-dev/demo/v1/demo%3Aemployee_picture

Response

The following response is expected:

Note: JSON returns a Base64-encoded icon string or a link to the actual picture or voice image using a /data/ link instead of a /rest/ link.

employee_id": 1,
    "icon": {
       "type": "base64",
       "length": 1185,
       "value": "iVBORw0KGgoAAAANSUhEUgAAA... (truncated)"
    },
    "picture": {
       "type": "base64",
       "length": 138795,
       "url": "https://server.acme.com/data/el-dev/demo/v1/demo:employee_picture/1/picture"
    },
    voice": {
       "type": "base64",
       "length": 127187,
       "url": "https://server.acme.com/data/el-dev/demo/v1/demo:employee_picture/1/voice"
    }

URI

Use the following URL:

https://demodev.espressologic.com/data/el-dev/demo/v1/demo:employee_picture/1/picture

Response

The following response is expected:

{
  "0": "�",
  "1": "P",
  "2": "N",
  "3": "G",
  "4": "
",
  "5": "
",
  "6": ".",
  "7": "
",
  "8": "",
  "9": "", truncated ...