Stream data type request examples
The following elements have the Stream data type:
- Images
- Files
- Binaries
Use the following standard methods to work with the Stream data type:
GET
– retrieve dataPOST
– add dataPUT
– modify dataDELETE
– delete data
Clear the browser cache to display Creatio request results when working with the Stream data type.
Retrieve data
Use the OData service to retrieve the “New user” contact's photo.
Implement the example
-
Retrieve the identifier of the “New user” contact's photo.
The contact's photo is stored in the
[Data]
column of the[SysImage]
database table. Run the following SQL query to retrieve the identifier of the “New user” contact's photo.- SQL query
- Response
select Id from SysImage where Id = (select PhotoId from Contact where Name = 'New user')
29FE7EDF-4DB9-4E09-92B0-018047BA1F71
-
Retrieve the “New user” contact's photo.
Execute the following request to retrieve the “New user” contact's photo.
- Request
- Response
- Results in Creatio
// Retrieve the [Data] field value for the 29FE7EDF-4DB9-4E09-92B0-018047BA1F71 [Id] object instance in the [SysImage] collection.
GET http://mycreatio.com/0/odata/SysImage(29FE7EDF-4DB9-4E09-92B0-018047BA1F71)/DataStatus: 200 OK
Add data
Use the OData service to add the “New user” contact. Then, add a photo to the contact.
Implement the example
-
Add the “New user” contact.
Creatio stores all contacts in the
[Contact]
database table. Execute the following request to add the “New user” contact.- Request
- Response
- Results in Creatio
// Add an object instance to the [Contact] collection.
POST http://mycreatio.com/0/odata/Contact
Accept: application/json; odata=verbose
Content-Type: application/json; odata=verbose; IEEE754Compatible=true
BPMCSRF: OpK/NuJJ1w/SQxmPvwNvfO
{
// Write the "New user" contact name to the [Name] field.
"Name": "New user"
}Status: 201 Created
{
"@odata.context": "http://mycreatio.com/0/odata/$metadata#Contact/$entity",
"Id": "4c63c8fa-467b-48a6-973f-b2069298404f",
"Name": "New user",
"OwnerId": "410006e1-ca4e-4502-a9ec-e54d922d2c00",
"CreatedOn": "2021-01-14T08:33:29.009023Z",
"CreatedById": "410006e1-ca4e-4502-a9ec-e54d922d2c00",
"ModifiedOn": "2021-01-14T08:33:29.009023Z",
"ModifiedById": "410006e1-ca4e-4502-a9ec-e54d922d2c00",
"ProcessListeners": 0,
"Dear": "",
"SalutationTypeId": "00000000-0000-0000-0000-000000000000",
"GenderId": "00000000-0000-0000-0000-000000000000",
"AccountId": "00000000-0000-0000-0000-000000000000",
"DecisionRoleId": "00000000-0000-0000-0000-000000000000",
"TypeId": "00000000-0000-0000-0000-000000000000",
"JobId": "00000000-0000-0000-0000-000000000000",
"JobTitle": "",
"DepartmentId": "00000000-0000-0000-0000-000000000000",
"BirthDate": "0001-01-01T00:00:00Z",
"Phone": "",
"MobilePhone": "",
"HomePhone": "",
"Skype": "",
"Email": "",
"AddressTypeId": "00000000-0000-0000-0000-000000000000",
"Address": "",
"CityId": "00000000-0000-0000-0000-000000000000",
"RegionId": "00000000-0000-0000-0000-000000000000",
"Zip": "",
"CountryId": "00000000-0000-0000-0000-000000000000",
"DoNotUseEmail": false,
"DoNotUseCall": false,
"DoNotUseFax": false,
"DoNotUseSms": false,
"DoNotUseMail": false,
"Notes": "",
"Facebook": "",
"LinkedIn": "",
"Twitter": "",
"FacebookId": "",
"LinkedInId": "",
"TwitterId": "",
"ContactPhoto@odata.mediaEditLink": "Contact(4c63c8fa-467b-48a6-973f-b2069298404f)/ContactPhoto",
"ContactPhoto@odata.mediaReadLink": "Contact(4c63c8fa-467b-48a6-973f-b2069298404f)/ContactPhoto",
"ContactPhoto@odata.mediaContentType": "application/octet-stream",
"TwitterAFDAId": "00000000-0000-0000-0000-000000000000",
"FacebookAFDAId": "00000000-0000-0000-0000-000000000000",
"LinkedInAFDAId": "00000000-0000-0000-0000-000000000000",
"PhotoId": "00000000-0000-0000-0000-000000000000",
"GPSN": "",
"GPSE": "",
"Surname": "user",
"GivenName": "New",
"MiddleName": "",
"Confirmed": true,
"IsNonActualEmail": false,
"Completeness": 0,
"LanguageId": "6ebc31fa-ee6c-48e9-81bf-8003ac03b019",
"Age": 0
}The “New user” contact identifier is “4c63c8fa-467b-48a6-973f-b2069298404f.”
-
Add a photo to the “New user” contact.
The contact photo must be stored in the
[Data]
column of the[SysImage]
database table. Since there is no table record for this contact, you must add it. Execute the following request to add a record to the table.- Request
- Response
// Add an object instance to the [SysImage] collection.
POST http://mycreatio.com/0/odata/SysImage
Accept: application/json; odata=verbose
Content-Type: application/json; odata=verbose; IEEE754Compatible=true
BPMCSRF: OpK/NuJJ1w/SQxmPvwNvfO
{
// Write the filename of the contact photo to the [Name] field.
"Name": "scr_NewContactPhoto.png",
// Write an arbitrary record identifier to the [Id] field of the [SysImage] table.
"Id": "410006E1-CA4E-4502-A9EC-E54D922D2C01",
// Write the file type of the contact photo to the [MimeType] field.
"MimeType": "image/png"
}Status: 201 Created
{
"@odata.context": "http://mycreatio.com/0/odata/$metadata#SysImage/$entity",
"Id": "410006e1-ca4e-4502-a9ec-e54d922d2c01",
"CreatedOn": "2021-01-14T08:52:47.7573789Z",
"CreatedById": "410006e1-ca4e-4502-a9ec-e54d922d2c00",
"ModifiedOn": "2021-01-14T08:52:47.7573789Z",
"ModifiedById": "410006e1-ca4e-4502-a9ec-e54d922d2c00",
"ProcessListeners": 0,
"UploadedOn": "0001-01-01T00:00:00Z",
"Name": "scr_NewContactPhoto.png",
"Data@odata.mediaEditLink": "SysImage(410006e1-ca4e-4502-a9ec-e54d922d2c01)/Data",
"Data@odata.mediaReadLink": "SysImage(410006e1-ca4e-4502-a9ec-e54d922d2c01)/Data",
"Data@odata.mediaContentType": "application/octet-stream",
"MimeType": "image/png",
"HasRef": false,
"PreviewData@odata.mediaEditLink": "SysImage(410006e1-ca4e-4502-a9ec-e54d922d2c01)/PreviewData",
"PreviewData@odata.mediaReadLink": "SysImage(410006e1-ca4e-4502-a9ec-e54d922d2c01)/PreviewData",
"PreviewData@odata.mediaContentType": "application/octet-stream"
}The record was added to the
[SysImage]
database table, however the value of the[Data]
column is “0x.”Pass the image in the request body. The image filename must match the value of the
[Name]
field. Execute the following request to add the contact photo to the[Data]
column.- Request
- Response
// Update the value of the [Data] field for the 410006e1-ca4e-4502-a9ec-e54d922d2c01 [Id] object instance in the [SysImage] collection.
PUT http://mycreatio.com/0/odata/SysImage(410006e1-ca4e-4502-a9ec-e54d922d2c01)/Data
Accept: application/json; text/plain; */*
Content-Type: application/octet-stream; IEEE754Compatible=true
BPMCSRF: OpK/NuJJ1w/SQxmPvwNvfOStatus: 200 OK
-
Bind the added photo to the “New user” contact.
Link the
[Data]
field of the[SysImage]
table to the[PhotoId]
field of the[Contact]
table to bind the photo to the “New user” contact. Execute the following request to set up the binding.- Request
- Response
- Results in Creatio
// Update the value of the [PhotoId] field for the 4c63c8fa-467b-48a6-973f-b2069298404f [Id] object instance in the [Contact] collection.
PATCH http://mycreatio.com/0/odata/Contact(4c63c8fa-467b-48a6-973f-b2069298404f)
Accept: application/json;odata=verbose
Content-Type: application/json; odata=verbose; IEEE754Compatible=true
BPMCSRF: OpK/NuJJ1w/SQxmPvwNvfO
{
// Write the identifier of the record in the [SysImage] table to the [PhotoId] field.
"PhotoId": "410006e1-ca4e-4502-a9ec-e54d922d2c01"
}Status: 204 No Content
Execute the following to add a photo to an existing contact:
- A
POST
request to add an object instance to the[SysImage]
collection. - A
PUT
request to update the value of the[Data]
field for the object instance in the[SysImage]
collection. - A
PATCH
request to bind the added photo to the “New user” contact.
Modify data
Use the OData service to update the photo of the existing “New user” contact.
Implement the example
-
Retrieve the identifier of the “New user” contact's photo.
The contact's photo is stored in the
[Data]
column of the[SysImage]
database table. Run the following SQL query to retrieve the identifier of the “New user” contact's photo.- SQL query
- Response
select Id from SysImage where Id = (select PhotoId from Contact where Name = 'New user')
29FE7EDF-4DB9-4E09-92B0-018047BA1F71
-
Update the “New user” contact's photo.
Execute the following request to update the “New user” contact's photo.
- Request
- Response
- Results in Creatio
// Update the [Data] field for the 29FE7EDF-4DB9-4E09-92B0-018047BA1F71 [Id] object instance in the [SysImage] collection.
PUT http://mycreatio.com/0/odata/SysImage(29FE7EDF-4DB9-4E09-92B0-018047BA1F71)/Data
Accept: application/json; text/plain; */*
Content-Type: application/octet-stream; IEEE754Compatible=true
BPMCSRF: OpK/NuJJ1w/SQxmPvwNvfOStatus: 200 OK
Delete data
Use the OData service to delete the photo of the “New user” contact.
Implement the example
-
Retrieve the identifier of the “New user” contact's photo.
The contact's photo is stored in the
[Data]
column of the[SysImage]
database table. Run the following SQL query to retrieve the identifier of the “New user” contact's photo.- SQL query
- Response
select Id from SysImage where Id = (select PhotoId from Contact where Name = 'New user')
29FE7EDF-4DB9-4E09-92B0-018047BA1F71
-
Delete the “New user” contact's photo.
Execute the following request to delete the “New user” contact's photo.
- Request
- Response
- Results in Creatio
// Delete the value of the [Data] field for the 29FE7EDF-4DB9-4E09-92B0-018047BA1F71 [Id] object instance in the [SysImage] collection.
DELETE http://mycreatio.com/0/odata/SysImage(29FE7EDF-4DB9-4E09-92B0-018047BA1F71)/Data
Accept: application/json; text/plain; */*
Content-Type: application/json; charset=utf-8; IEEE754Compatible=true
BPMCSRF: OpK/NuJJ1w/SQxmPvwNvfOStatus: 204 No Content