Univention Bugzilla – Bug 50023
[UDM HTTP API] patch document requires options, policies and position
Last modified: 2019-09-22 15:51:13 CEST
One of the most common use cases for the UDM HTTP API is changing an objects property. This cannot be easily done, because the patch document requires "options", "policies" and "position" to be set. To do that a search and download of the object is first necessary. Make "options", "policies" and "position" optional in patch documents.
Okay, changed so that nothing needs to be set. In most cases it is probably better to make a GET request, modify the content you get and send this via PUT. Fixed in, no package build, will be done soon via Bug #27816: dcb1d32645bb | Bug #27816: Bug #50023: add defaults in PATCH method
OK: code change OK: tested PATCH for single "properties" and "options": $ univention-ldapsearch -LLL uid=demo_student sn dn: uid=demo_student,cn=schueler,cn=users,ou=DEMOSCHOOL,dc=uni,dc=dtr sn: Student $ curl -i -X PATCH -H "Accept:application/json" -H "Content-Type:application/json" -u Administrator:univention -d '{"properties": {"lastname": "Studi"}}' 'http://10.200.3.66/univention/udm/users/user/uid=demo_student,cn=schueler,cn=users,ou=DEMOSCHOOL,dc=uni,dc=dtr' $ univention-ldapsearch -LLL uid=demo_student sn dn: uid=demo_student,cn=schueler,cn=users,ou=DEMOSCHOOL,dc=uni,dc=dtr sn: Studi ----------------------------------------------------------------- $ univention-ldapsearch -LLL uid=demo_teacher objectClass | grep ucsschool objectClass: ucsschoolTeacher objectClass: ucsschoolType $ curl -i -X PATCH -H "Accept:application/json" -H "Content-Type:application/json" -u Administrator:univention -d '{"options": {"ucsschoolStaff": true}}' 'http://10.200.3.66/univention/udm/users/user/uid=demo_teacher,cn=lehrer,cn=users,ou=DEMOSCHOOL,dc=uni,dc=dtr' $ univention-ldapsearch -LLL uid=demo_teacher objectClass | grep ucsschool objectClass: ucsschoolType objectClass: ucsschoolStaff objectClass: ucsschoolTeacher ----------------------------------------------------------------- $ curl -i -X PATCH -H "Accept:application/json" -H "Content-Type:application/json" -u Administrator:univention -d '{"options": {"ucsschoolStaff": false}}' 'http://10.200.3.66/univention/udm/users/user/uid=demo_teacher,cn=lehrer,cn=users,ou=DEMOSCHOOL,dc=uni,dc=dtr' $ univention-ldapsearch -LLL uid=demo_teacher objectClass | grep ucsschool objectClass: ucsschoolType objectClass: ucsschoolTeacher ----------------------------------------------------------------- $ univention-ldapsearch -LLL cn=lehrer-schulezwei univentionPolicyReference dn: cn=lehrer-schulezwei,cn=groups,ou=SchuleZwei,dc=uni,dc=dtr univentionPolicyReference: cn=ucsschool-umc-teachers-default,cn=UMC,cn=policies,dc=uni,dc=dtr $ curl -i -X PATCH -H "Accept:application/json" -H "Content-Type:application/json" -u Administrator:univention -d '{"policies": {"policies/registry": ["cn=ou-default-ucr-policy,cn=policies,ou=demoschool,dc=uni,dc=dtr"]}}' 'http://10.200.3.66/univention/udm/groups/group/cn=lehrer-schulezwei,cn=groups,ou=SchuleZwei,dc=uni,dc=dtr' $ univention-ldapsearch -LLL cn=lehrer-schulezwei univentionPolicyReference dn: cn=lehrer-schulezwei,cn=groups,ou=SchuleZwei,dc=uni,dc=dtr univentionPolicyReference: cn=ou-default-ucr-policy,cn=policies,ou=demoschool,dc=uni,dc=dtr $ curl -i -X PATCH -H "Accept:application/json" -H "Content-Type:application/json" -u Administrator:univention -d '{"policies": {"policies/umc": ["cn=ucsschool-umc-teachers-default,cn=UMC,cn=policies,dc=uni,dc=dtr"]}}' 'http://10.200.3.66/univention/udm/groups/group/cn=lehrer-schulezwei,cn=groups,ou=SchuleZwei,dc=uni,dc=dtr' $ univention-ldapsearch -LLL cn=lehrer-schulezwei univentionPolicyReference dn: cn=lehrer-schulezwei,cn=groups,ou=SchuleZwei,dc=uni,dc=dtr univentionPolicyReference: cn=ucsschool-umc-teachers-default,cn=UMC,cn=policies,dc=uni,dc=dtr
<http://errata.software-univention.de/ucs/4.4/282.html>