Skip to main content
Version: 6.0.0

AwardUserItem

Allows item(s) to be awarded to a user without collecting the purchase amount. If includeDef is true, response includes associated itemDef with language fields limited to the current or default language.

note

Awarding 0 or negative userItem will return an error. Use DropUserItme to remove usertem.

caution

For security reasons calling this API from the client is not recommended, and is rejected at the server by default. To over-ride, enable the 'Allow AwardUserItem to be called from client (not recommended)' compatibility setting in the Design Portal.

ServiceOperation
userItemsAWARD_USER_ITEM

Method Parameters

ParameterDescription
defIdThe unique id of the item definition to award.
quantityThe quantity of the item to award.
includeDefIf true, the associated item definition will be included in the response.

Usage

http://localhost:3000
string defId = "sword001";
int quantity = 1;
bool includeDef = true;
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.UserItemsService.awardUserItem(defId, quantity, includeDef, successCallback, failureCallback);
JSON Response
{
"data": {
"items": {
"d01c70b8-b1a1-457e-ba14-dd52909ffc4a": {
"itemId": "d01c70b8-b1a1-457e-ba14-dd52909ffc4a",
"defId": "medal_bronze_1",
"quantity": 1,
"usesLeft": null,
"coolDownStart": -1,
"recoveryStart": -1,
"itemData": {
"exp": 0
},
"giftedTo": null,
"giftedFrom": null,
"blockId": null,
"createdAt": 1566847876350,
"updatedAt": 1566847876350,
"version": 1,
"maxUses": null,
"coolDownUntil": -1,
"recoveryUntil": -1,
"itemDef": {
"defId": "medal_bronze_1",
"name": "Small Bronze Medal",
"desc": "",
"type": "ITEM",
"category": "collectable",
"tags": [
"medal"
],
"buyPrice": {
"coins": 2000
},
"sellPrice": {
"coins": 200
},
"image": "https://api.braincloudservers.com/files/portal/g/00000/metadata/itemDefinitions/medal_bronze_1.png",
"resourceGroup": null,
"resourceTag": null,
"meta": {
"level": "bronze"
},
"pState": "PUBLISHED",
"publishedAt": 1566584361752,
"stackable": true,
"consumable": false,
"uses": null,
"coolDownSecs": 0,
"recoverySecs": 0,
"activatable": false,
"statusName": null,
"activeSecs": null,
"tradable": false,
"blockchain": false,
"blockchainDefId": null
}
}
}
},
"status": 200
}