Tracking codes data type and manipulation

柔情痞子 提交于 2019-12-20 06:33:56

问题


Tracking codes allow an enterprise (such as us) to store some local ID in the users' data on Box. I realize that the functionality needs to be enabled on the enterprise (which our contacts are working on).

First question: The documentation says it's an "array", and other answers indicate that it's an array of "name/value pairs". In datatypes, what exactly does Box API consider to be a "name/value"-pair?

Is it a list of dictionaries with string keys and string values (and in that case - what happens if two of the dictionaries share keys), a list of strings with a "/" separator, or can I put any data type I like into the array?

Second question: do I manipulate the tracking_codes array like a normal attribute (i.e. do i PUT a new array to /2.0/users/USERID to update it), or do I manage it like other arrays (such as email aliases) by POST/DELETE to /2.0/users/USERID/tracking_codes?

Thank you.


回答1:


Ok... No answers here, and none from Box support, so I experimented and contacted another enterprise whose working script I could use as a base.

  1. "tracking_codes" need to be enabled for the enteprise. The documentation does not mention this. If you don't enable tracking_codes, you get the standard and very unhelpful "invalid request parameters" error.

  2. The names of the specific tracking_codes you intend to use must be registered in the "enterprise settings" ("user settings" tab) of Box' administration pages. The documentation wrongly says that "any name/value pair" can be used, but only names that are pre-registered work. If you use a name that hasn't been registered, you get the unhelpful "invalid request parameters" error.

  3. To set a tracking_code, you update the list of tracking_codes as an attribute. The format of each name/value pair must be: {"type": "tracking_code", "name": "[a name you have registered]", "value": "[any string]"}. So for example, if you've registered "personid" as a valid tracking_code, you can PUT to /2.0/users/[userid] the body

    {"tracking_codes": [{"type": "tracking_code", "name": "personid", "value": "1318231313"}]}
  4. I have not found any way to remove a tracking_code once set. PUT:ing an empty list does nothing. The best possibility seems to be putting an empty string as value for the tracking code, but it is still returned of course.



来源:https://stackoverflow.com/questions/22016507/tracking-codes-data-type-and-manipulation

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!