【发布时间】:2018-12-28 07:16:23
【问题描述】:
我正在尝试为我的 Android 项目 Work profile 实施 Android Management API。 this 链接提供了注册企业、创建策略和配置设备的快速入门指南。
我猜这个快速入门是用 Python 编写的Colab notebook(正如错误所暗示的那样)。我已经在这个 colab 笔记本中成功创建了一个企业,要创建一个我需要运行此代码的基本策略
import json
policy_name = enterprise_name + '/policies/policy1'
policy_json = '''
{
"applications": [
{
"packageName": "com.android.chrome",
"installType": "FORCE_INSTALLED"
}
],
"debuggingFeaturesAllowed": true
}
'''
androidmanagement.enterprises().policies().patch(
name=policy_name,
body=json.loads(policy_json)
).execute()
这是我按下运行图标时遇到的错误:
TypeError Traceback (most recent call last)
<ipython-input-7-fa6c551fe8df> in <module>()
17 androidmanagement.enterprises().policies().patch(
18 name=policy_name,
---> 19 body=json.loads(policy_json)
20 ).execute()
/usr/local/lib/python3.6/dist-packages/googleapiclient/discovery.py in method(self, **kwargs)
740 raise TypeError(
741 'Parameter "%s" value "%s" does not match the pattern "%s"' %
--> 742 (name, pvalue, regex))
743
744 for name, enums in six.iteritems(parameters.enum_params):
TypeError: Parameter "name" value "LC01gzjgxa/policies/policy1" does not match the pattern "^enterprises/[^/]+/policies/[^/]+$"
谁能帮我解决这个错误?
【问题讨论】:
-
TypeError: 参数“name”值“LC01gzjgxa/policies/policy1”与模式“^enterprises/[^/]+/policies/[^/]+$”不匹配按照这个你企业名称和策略名称不匹配
-
这个错误与值或模式有关?
-
我认为有模式,应该是这样的企业/LC01gzjgxa/policies/policy1
-
成功了!非常感谢 :) 在使用 enterprise_name 之前需要附加 'enterprises/'。
标签: android python-3.x google-colaboratory android-management-api android-managed-profile