#1 2015-12-10 09:27:14

alexdmatveev
Member
Registered: 2014-09-12
Posts: 87

Add a object with blob in one POST

Hello gurus,

Is it possible to add and object with blobs with one POST request?

With other words:

with 2 POSTs:

Result := ConnectionManager.DocumentClient.Add(msg.Details, true) >= 0;
ConnectionManager.DocumentClient.UpdateBlobFields(msg.Details);

I tryed to make it with batch:

  ConnectionManager.DocumentClient.BatchStart(msg.Details.RecordClass);
  ConnectionManager.DocumentClient.BatchAdd(msg.Details, True, False);
  ConnectionManager.DocumentClient.BatchUpdate(msg.Details, 'Document');
  res := ConnectionManager.DocumentClient.BatchSend(ids);
  Result := res = HTML_SUCCESS;

but I have an exception on the server:

20151210 10125718 EXC   EORMBatchException {"Message":"TSQLRestServerDB.EngineBatchSend: Missing ["} at 005A0712  stack trace 00596B66 0598425 005BE8DF 005233A7 004E59CB 00522E9F 00522ECC 00522F56 004BBD84 0040AD2A 764C3677 77529F42 77529F15

I use:
1. Delphi XE7
2. CrossPlatform client
3. server is based on mongoDB

and common question:

what is the optiomal way to ADD full objects with blobs?
Pls show me the way.


Thanks a lot.

Offline

#2 2015-12-10 14:36:54

oz
Member
Registered: 2015-09-02
Posts: 95

Re: Add a object with blob in one POST

On Batch-Level use following overloaded method: TSQLRestBatch.Add(Value: TSQLRecord; SendData,ForceID: boolean; const CustomFields: TSQLFieldBits; DoNotAutoComputeFields: boolean): integer;


This would send all fields, including Blobs:

ConnectionManager.DocumentClient.BatchAdd(msg.Details, True, False, ALL_FIELDS);

Offline

#3 2015-12-10 14:59:29

alexdmatveev
Member
Registered: 2014-09-12
Posts: 87

Re: Add a object with blob in one POST

Thanks for your answer.

I use crossplatform library.
The syntax is little bit other:

ConnectionManager.DocumentClient.BatchAdd(msg.Details, True, False, '*');

and when I use it I have the same error

20151210 10125718 EXC   EORMBatchException {"Message":"TSQLRestServerDB.EngineBatchSend: Missing ["} at 005A0712  stack trace 00596B66 0598425 005BE8DF 005233A7 004E59CB 00522E9F 00522ECC 00522F56 004BBD84 0040AD2A 764C3677 77529F42 77529F15

Offline

#4 2015-12-10 15:48:40

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,240
Website

Re: Add a object with blob in one POST

Are you using the latest version of the framework source code?

Offline

#5 2015-12-10 16:02:50

alexdmatveev
Member
Registered: 2014-09-12
Posts: 87

Re: Add a object with blob in one POST

Just updated.

You have saved my night smile

Thanks a lot. Works fine.

Offline

Board footer

Powered by FluxBB