I'm trying to implement Android Management API for my Android project Work profile
. this link provides a Quickstart guide to enroll an enterprise, create a policy, and provision a device.
The Quickstart is a Colab notebook
written in Python I guess (as the error suggests). I've successfully created an enterprise in this colab notebook, to create a basic policy I need to run this code
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()
and this is the error I'm getting as I press run icon:
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/[^/]+$"
Can someone help me solve this error?
TypeError: Parameter "name" value "LC01gzjgxa/policies/policy1" does not match the pattern "^enterprises/[^/]+/policies/[^/]+$"
As per this error log, your enterprise_name and policy name not matching with the pattern which is expected.
it should be something like this enterprises/enterprise_name/policies/policy_name
. So try to change it like below.
enterprises/LC01gzjgxa/policies/policy1