{"_id":"56c41ccf54b6030d00ec29aa","parentDoc":null,"category":{"_id":"56c4183bbb64720d00552b88","__v":6,"pages":["56c41cc5521f350d00d34901","56c41ccf54b6030d00ec29aa","56c41cdd54b6030d00ec29ac","56c41ce7106c12170020dba4","56c41cee2d97560d00e23cff","56c41cf72d97560d00e23d01"],"project":"56bc8e679afb8b0d00d62dcf","version":"56bc8e689afb8b0d00d62dd2","sync":{"url":"","isSync":false},"reference":true,"createdAt":"2016-02-17T06:50:35.303Z","from_sync":false,"order":4,"slug":"metadata","title":"Metadata"},"githubsync":"","user":"56b98db7bb36440d0001f492","project":"56bc8e679afb8b0d00d62dcf","version":{"_id":"56bc8e689afb8b0d00d62dd2","project":"56bc8e679afb8b0d00d62dcf","__v":18,"createdAt":"2016-02-11T13:36:40.146Z","releaseDate":"2016-02-11T13:36:40.146Z","categories":["56bc8e689afb8b0d00d62dd3","56c3c837bc41330d009f25ed","56c3c83e521f350d00d348eb","56c3c8452d97560d00e23cd8","56c3c85234df460d00c2beb8","56c4180d70187b17005f43b4","56c418162d97560d00e23cf6","56c4181cc4796b0d007ef039","56c4182370187b17005f43b5","56c418292e75e01700986052","56c4183328bd680d005e7ac6","56c4183bbb64720d00552b88","56c418414040602b0064cea0","56c4184754b6030d00ec29a1","56c4184c28bd680d005e7ac7","56c4185370187b17005f43b6","56c4185b6063071700500cfc","582a98b6f8c0a0190053d7a5"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"__v":6,"updates":["591f1ca5654ef6190043a573"],"next":{"pages":[],"description":""},"createdAt":"2016-02-17T07:10:07.791Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":true,"order":1,"body":"[block:api-header]\n{\n  \"type\": \"put\",\n  \"title\": \"/metadata/{id}\"\n}\n[/block]\nStores multiple key/value pairs as metadata. An ID can be used to associate the metadata with an existing Buddy object (a user, picture, message, etc). If no ID is specified the data is stored at the application level and not associated with an object.\n\nThe metadata value visibility scope can be specified with the `visibility` parameter. Setting `visibility` to `User` creates private metadata; only the user who creates the key will be able to see and access the metadata. `App` visibility lets any app user view or modify the value.\n\n_If a key/value pair exists already, then the specified value will be overwritten._\n\n**Note:** Key values can not have \".\" in them\n\n**Note:** The values `app` and `me` can be used in place of an `{id}` for application and user-specific metadata.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var options = {\\n\\tkeyValuePairs: {Key1: 'value 1', Key2: 'value 2'},\\n\\tvisibility: \\\"App\\\",\\n\\tlocation: \\\"47.1, -121.292\\\",\\n\\tpermissions: \\\"User\\\",\\n\\tlastModified: \\\"2014/6/01-2014/12/31\\\"\\n};\\n\\nBuddy.put('/metadata/my_id',\\n\\t\\toptions,\\n\\t\\tfunction(err, result) {\\n\\t\\t\\t \\n\\t\\t\\tif (result.success) {\\n\\t\\t\\t\\t// Do something with the result!\\n\\t\\t\\t} else { \\n\\t\\t\\t\\t// Otherwise log the error\\n\\t\\t\\t\\tconsole.log(err); \\n\\t\\t\\t} \\n\\t\\t}\\n\\t);\",\n      \"language\": \"javascript\"\n    },\n    {\n      \"code\": \"var options = {\\n\\tkeyValuePairs: {Key1: 'value 1', Key2: 'value 2'},\\n\\tvisibility: \\\"App\\\",\\n\\tlocation: \\\"47.1, -121.292\\\",\\n\\tpermissions: \\\"User\\\",\\n\\tlastModified: \\\"2014/6/01-2014/12/31\\\"\\n};\\n\\nBuddy.put('/metadata/my_id',\\n\\t\\toptions,\\n\\t\\tfunction(err, result) {\\n\\t\\t\\t \\n\\t\\t\\tif (result.success) {\\n\\t\\t\\t\\t// Do something with the result!\\n\\t\\t\\t} else { \\n\\t\\t\\t\\t// Otherwise log the error\\n\\t\\t\\t\\tconsole.log(err); \\n\\t\\t\\t} \\n\\t\\t}\\n\\t);\",\n      \"language\": \"objectivec\",\n      \"name\": \"iOS\"\n    },\n    {\n      \"code\": \"Map<String, Object> parameters = new HashMap<String, Object>();\\nparameters.put(\\\"keyValuePairs\\\", \\\"{'Key1': 'value 1', 'Key2': 'value 2'}\\\");\\nparameters.put(\\\"visibility\\\", \\\"App\\\");\\nparameters.put(\\\"location\\\", myLocation);\\nparameters.put(\\\"permissions\\\", \\\"User\\\");\\nparameters.put(\\\"lastModified\\\", \\\"2014/6/01-2014/12/31\\\");\\n\\nBuddy.<Boolean>put(\\\"/metadata/my_id\\\", parameters, new BuddyCallback<Boolean>(Boolean.class) {\\n\\t:::at:::Override\\n\\tpublic void completed(BuddyResult<Boolean> result) {\\n\\t\\t// Your callback code here\\n\\t}\\n});\",\n      \"language\": \"java\",\n      \"name\": \"Android\"\n    },\n    {\n      \"code\": \"var options = new {\\n\\t\\t\\tkeyValuePairs = \\\"{'Key1': 'value 1', 'Key2': 'value 2'}\\\",\\n\\t\\t\\tvisibility = \\\"App\\\",\\n\\t\\t\\tlocation = new BuddyGeoLocation(47.1, -122.3),\\n\\t\\t\\tpermissions = \\\"User\\\",\\n\\t\\t\\tlastModified = \\\"2014/6/01-2014/12/31\\\"\\n\\t\\t};\\n\\nvar result = await Buddy.PutAsync<bool>(\\\"/metadata/my_id\\\", options);\",\n      \"language\": \"csharp\",\n      \"name\": \".NET\"\n    }\n  ],\n  \"sidebar\": true\n}\n[/block]\n###Path Parameters\n\nThese parameters should be specified as part of the HTTP path.\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"id\",\n    \"0-1\": \"The ID of an existing Buddy object (e.g. user, picture, etc.) to associate the metadata with. To associate metadata with the application, the helper value app can be specified.\",\n    \"0-2\": \"buddyId\",\n    \"0-3\": \"Required\"\n  },\n  \"cols\": 4,\n  \"rows\": 1\n}\n[/block]\n###Body Parameters\n\nThese parameters should be specified as part of the request body.\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"keyValuePairs\",\n    \"1-0\": \"visibility\",\n    \"2-0\": \"location\",\n    \"3-0\": \"permissions\",\n    \"4-0\": \"lastModified\",\n    \"0-1\": \"A collection of key/value pairs to store as metadata. The format is:\\n```\\n{\\n   \\\"key1\\\":\\\"value1\\\",\\n   \\\"key2\\\":\\\"value2\\\"\\n}\\n```\",\n    \"1-1\": \"Specifies the visibility of this item. Values are User, which means only the user that created the value can access or modify it, or App, which allows any app code to view the value.\",\n    \"2-1\": \"A location value, passed as a string in the format \\\"{latitude},{longitude}\\\" (e.g. \\\"47.1,-121.292\\\").\",\n    \"3-1\": \"Specifies who can view or modify this item. Values are User, which means only the user that created the value can access or modify it, or App, which allows any app code to access and modify the value.\",\n    \"4-1\": \"A range of dates to to search. Valid date formats include UTC timestamps specified as Unix ticks (milliseconds since Jan 1, 1970) such as \\\"136512000000-1398816000000\\\" and common date formats such as \\\"2012/1/27-2014/5/6\\\".\",\n    \"0-2\": \"string\",\n    \"1-2\": \"string\",\n    \"2-2\": \"string\",\n    \"3-2\": \"string\",\n    \"4-2\": \"string\",\n    \"0-3\": \"Required\",\n    \"1-3\": \"Optional\",\n    \"2-3\": \"Optional\",\n    \"3-3\": \"Optional\",\n    \"4-3\": \"Optional\"\n  },\n  \"cols\": 4,\n  \"rows\": 5\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n    \\\"status\\\": 200,\\n    \\\"result\\\": true,\\n    \\\"request_id\\\": \\\"27ede5fa-5f7d-4d21-b6c0-5ce323d7edf6\\\",\\n    \\\"success\\\": true\\n}\",\n      \"language\": \"json\",\n      \"name\": \"Response\"\n    }\n  ],\n  \"sidebar\": true\n}\n[/block]","excerpt":"","slug":"set-metadata-values","type":"basic","title":"Set Metadata Values"}

Set Metadata Values


[block:api-header] { "type": "put", "title": "/metadata/{id}" } [/block] Stores multiple key/value pairs as metadata. An ID can be used to associate the metadata with an existing Buddy object (a user, picture, message, etc). If no ID is specified the data is stored at the application level and not associated with an object. The metadata value visibility scope can be specified with the `visibility` parameter. Setting `visibility` to `User` creates private metadata; only the user who creates the key will be able to see and access the metadata. `App` visibility lets any app user view or modify the value. _If a key/value pair exists already, then the specified value will be overwritten._ **Note:** Key values can not have "." in them **Note:** The values `app` and `me` can be used in place of an `{id}` for application and user-specific metadata. [block:code] { "codes": [ { "code": "var options = {\n\tkeyValuePairs: {Key1: 'value 1', Key2: 'value 2'},\n\tvisibility: \"App\",\n\tlocation: \"47.1, -121.292\",\n\tpermissions: \"User\",\n\tlastModified: \"2014/6/01-2014/12/31\"\n};\n\nBuddy.put('/metadata/my_id',\n\t\toptions,\n\t\tfunction(err, result) {\n\t\t\t \n\t\t\tif (result.success) {\n\t\t\t\t// Do something with the result!\n\t\t\t} else { \n\t\t\t\t// Otherwise log the error\n\t\t\t\tconsole.log(err); \n\t\t\t} \n\t\t}\n\t);", "language": "javascript" }, { "code": "var options = {\n\tkeyValuePairs: {Key1: 'value 1', Key2: 'value 2'},\n\tvisibility: \"App\",\n\tlocation: \"47.1, -121.292\",\n\tpermissions: \"User\",\n\tlastModified: \"2014/6/01-2014/12/31\"\n};\n\nBuddy.put('/metadata/my_id',\n\t\toptions,\n\t\tfunction(err, result) {\n\t\t\t \n\t\t\tif (result.success) {\n\t\t\t\t// Do something with the result!\n\t\t\t} else { \n\t\t\t\t// Otherwise log the error\n\t\t\t\tconsole.log(err); \n\t\t\t} \n\t\t}\n\t);", "language": "objectivec", "name": "iOS" }, { "code": "Map<String, Object> parameters = new HashMap<String, Object>();\nparameters.put(\"keyValuePairs\", \"{'Key1': 'value 1', 'Key2': 'value 2'}\");\nparameters.put(\"visibility\", \"App\");\nparameters.put(\"location\", myLocation);\nparameters.put(\"permissions\", \"User\");\nparameters.put(\"lastModified\", \"2014/6/01-2014/12/31\");\n\nBuddy.<Boolean>put(\"/metadata/my_id\", parameters, new BuddyCallback<Boolean>(Boolean.class) {\n\[email protected]\n\tpublic void completed(BuddyResult<Boolean> result) {\n\t\t// Your callback code here\n\t}\n});", "language": "java", "name": "Android" }, { "code": "var options = new {\n\t\t\tkeyValuePairs = \"{'Key1': 'value 1', 'Key2': 'value 2'}\",\n\t\t\tvisibility = \"App\",\n\t\t\tlocation = new BuddyGeoLocation(47.1, -122.3),\n\t\t\tpermissions = \"User\",\n\t\t\tlastModified = \"2014/6/01-2014/12/31\"\n\t\t};\n\nvar result = await Buddy.PutAsync<bool>(\"/metadata/my_id\", options);", "language": "csharp", "name": ".NET" } ], "sidebar": true } [/block] ###Path Parameters These parameters should be specified as part of the HTTP path. [block:parameters] { "data": { "0-0": "id", "0-1": "The ID of an existing Buddy object (e.g. user, picture, etc.) to associate the metadata with. To associate metadata with the application, the helper value app can be specified.", "0-2": "buddyId", "0-3": "Required" }, "cols": 4, "rows": 1 } [/block] ###Body Parameters These parameters should be specified as part of the request body. [block:parameters] { "data": { "0-0": "keyValuePairs", "1-0": "visibility", "2-0": "location", "3-0": "permissions", "4-0": "lastModified", "0-1": "A collection of key/value pairs to store as metadata. The format is:\n```\n{\n \"key1\":\"value1\",\n \"key2\":\"value2\"\n}\n```", "1-1": "Specifies the visibility of this item. Values are User, which means only the user that created the value can access or modify it, or App, which allows any app code to view the value.", "2-1": "A location value, passed as a string in the format \"{latitude},{longitude}\" (e.g. \"47.1,-121.292\").", "3-1": "Specifies who can view or modify this item. Values are User, which means only the user that created the value can access or modify it, or App, which allows any app code to access and modify the value.", "4-1": "A range of dates to to search. Valid date formats include UTC timestamps specified as Unix ticks (milliseconds since Jan 1, 1970) such as \"136512000000-1398816000000\" and common date formats such as \"2012/1/27-2014/5/6\".", "0-2": "string", "1-2": "string", "2-2": "string", "3-2": "string", "4-2": "string", "0-3": "Required", "1-3": "Optional", "2-3": "Optional", "3-3": "Optional", "4-3": "Optional" }, "cols": 4, "rows": 5 } [/block] [block:code] { "codes": [ { "code": "{\n \"status\": 200,\n \"result\": true,\n \"request_id\": \"27ede5fa-5f7d-4d21-b6c0-5ce323d7edf6\",\n \"success\": true\n}", "language": "json", "name": "Response" } ], "sidebar": true } [/block]