UpdateSharedEntity
Method updates a shared entity owned by another user. This operation results in the entity data being completely replaced by the passed in JSON string.
This method is affected by versioning. See the versioning documentation for more information.
Service | Operation |
---|---|
entity | UPDATE_SHARED |
Method Parameters
Parameter | Description |
---|---|
entityId | The id of the entity to update |
targetProfileId | The id of the entity's owner |
entityType | The entity type as defined by the user |
data | The entity's data object |
version | The version of the entity to update. Use -1 to indicate the newest version |
Usage
http://localhost:3000
- C#
- C++
- Objective-C
- Java
- JavaScript
- Dart
- Cloud Code
- Raw
string entityId = "someEntityId";
string targetProfileId = "someProfileId";
string entityType = "address";
string jsonEntityData = "{\"street\":\"1309 Carling Avenue, Ottawa, ON\"}";
int version = -1;
SuccessCallback successCallback = (response, cbObject) =>
{
Debug.Log(string.Format("Success | {0}", response));
};
FailureCallback failureCallback = (status, code, error, cbObject) =>
{
Debug.Log(string.Format("Failed | {0} {1} {2}", status, code, error));
};
_bc.EntityService.UpdateSharedEntity(entityId, targetProfileId, entityType, jsonEntityData, version, successCallback, failureCallback);
const char *entityId = "someEntityId";
const char *targetProfileId = "someProfileId";
const char *entityType = "address";
const char *jsonEntityData = "{\"street\":\"1309 Carling Avenue, Ottawa, ON\"}";
int version = -1;
_bc->getEntityService()->updateSharedEntity(entityId, targetProfileId, entityType, jsonEntityData, version, this);
NSString *entityId = @"someEntityId";
NSString *targetProfileId = @"someProfileId";
NSString *entityType = @"address";
NSString *jsonEntityData = @"{\"street\":\"1309 Carling Avenue, Ottawa, ON\"}";
int version = -1;
BCCompletionBlock successBlock; // define callback
BCErrorCompletionBlock failureBlock; // define callback
[[_bc entityService] updateSharedEntity:entityId
targetProfileId:targetProfileId
entityType:entityType
jsonEntityData:jsonEntityData
version:version
completionBlock:successBlock
errorCompletionBlock:failureBlock
cbObject:nil];
String entityId = "someEntityId";
String targetProfileId = "someProfileId";
String entityType = "address";
String jsonEntityData = "{\"street\":\"1309 Carling Avenue, Ottawa, ON\"}";
int version = -1;
this; // implements IServerCallback
_bc.getEntityService().updateSharedEntity(entityId, targetProfileId, entityType, jsonEntityData, version, this);
public void serverCallback(ServiceName serviceName, ServiceOperation serviceOperation, JSONObject jsonData)
{
System.out.print(String.format("Success | %s", jsonData.toString()));
}
public void serverError(ServiceName serviceName, ServiceOperation serviceOperation, int statusCode, int reasonCode, String jsonError)
{
System.out.print(String.format("Failed | %d %d %s", statusCode, reasonCode, jsonError.toString()));
}
var entityId = "someEntityId";
var targetProfileId = "someProfileId";
var entityType = "address";
var jsonEntityData = {
"street": "1309 Carling Avenue, Ottawa, ON"
};
var version = -1;
_bc.entity.updateSharedEntity(entityId, targetProfileId, entityType, jsonEntityData, version, result =>
{
var status = result.status;
console.log(status + " : " + JSON.stringify(result, null, 2));
});
var entityId = "someEntityId";
var targetProfileId = "someProfileId";
var entityType = "address";
var jsonEntityData = {
"street": "1309 Carling Avenue, Ottawa, ON"
};
var version = -1;
ServerResponse result = await _bc.entityService.updateSharedEntity(entityId:entityId, targetProfileId:targetProfileId, entityType:entityType, jsonEntityData:jsonEntityData, version:version);
if (result.statusCode == 200) {
print("Success");
} else {
print("Failed ${result.error['status_message'] ?? result.error}");
}
var entityId = "someEntityId";
var targetProfileId = "someProfileId";
var entityType = "address";
var jsonEntityData = {
"street": "1309 Carling Avenue, Ottawa, ON"
};
var version = -1;
var entityProxy = bridge.getEntityServiceProxy();
var postResult = entityProxy.updateSharedEntity(entityId, targetProfileId, entityType, jsonEntityData, version);
if (postResult.status == 200) {
// Success!
}
{
"service": "entity",
"operation": "UPDATE_SHARED",
"data": {
"entityId": "someEntityId",
"targetProfileId": "someProfileId",
"entityType": "address",
"data": {
"street": "1309 Carling Avenue, Ottawa, ON"
},
"version": -1
}
}
JSON Response
{
"status": 200,
"data": {
"entityId": "113db68a-48ad-4fc9-9f44-5fd36fc6445f",
"entityType": "person",
"version": 1,
"data": {
"name": "john",
"age": 30
},
"acl": {
"other": 0
},
"createdAt": 1395943044322,
"updatedAt": 1395943044322
}
}
Common Error Code
Status Codes
Code | Name | Description |
---|---|---|
40332 | UPDATE_FAILED | An update operation failed. Used for entities, global entities, and updates on the user. |