Zuweisung einer Person zu einer Personengruppe per API funktioniert nicht
-
Hallo,
in der Category "Person group memberships" ist dokumentiert, dass das Feld "Person group memberships" vom Typ Integer[] ist.
Quelle: Administration - Interfaces - external data - JSON-RPC API - Categories and attributes - Category : Person group membership C__CATS__PERSON_ASSIGNED_GROUPS)
Verwende ich im Aufruf ein Integer-Array, erscheint ein Datenbankfehler:
Aufruf:
curl -k -u "very:secret" -H "Content-Type: application/json" -X POST -d "{ "objid" : 29, "category" : "C__CATS__PERSON_ASSIGNED_GROUPS", "data" : { "connected_object" : [ 35 ], "contact" : 29 } }" http://localhost:4321/latest/category
{
"id": 0,
"success": false,
"message": "Internal error: An database error occurred that indicates that you provided an Id which does not exist. \n Please check all properties which are referencing an entry for validity: FOREIGN KEY (isys_person_2_group__isys_obj__id__group) REFERENCESisys_obj(isys_obj__id) ON DELETE CASCADE ON)"
}Auszug aus dem API-Log:
[2019-02-25 10:02:05 588697] DEBUG: Calculated model parameters based on method "cmdb.category.save"":
[
"category",
{
"object": 29,
"category": "C__CATS__PERSON_ASSIGNED_GROUPS",
"data": {
"contact": 29,
"connected_object": [
35
]
},
"objID": 29,
"apikey": "xmreky8lf404k0oo",
"language": "en",
"option": "save"
}
]
[2019-02-25 10:02:05 588812] DEBUG: Prepare to run request...
[2019-02-25 10:02:05 590261] INFO: Method: save
[2019-02-25 10:02:05 600389] ERROR: An exception occured while processing request: -32603 Internal error: An database error occurred that indicates that you provided an Id which does not exist.
Please check all properties which are referencing an entry for validity: FOREIGN KEY (isys_person_2_group__isys_obj__id__group) REFERENCESisys_obj(i sys_obj__id) ON DELETE CASCADE ON)
{
"mysqlErrorCode": 1452,
"mysqlErrorMessage": "Database error : Query error: 'INSERT INTO isys_person_2_group SET isys_person_2_group__isys_obj__id__person = '29', isys_person_2_group__isys_obj__id__group = 'Array';':\nCannot add or update a child row: a foreign key constraint fails (idoit_data.isys_person_2_group, CONSTRAINTisys_person_2_group_ibfk_2FOREIGN KEY (isys_person_2_group__isys_obj__id__group) REFERENCESisys_obj(isys_obj__id) ON DELETE CASCADE ON)\n"
}Verwende ich im Aufruf anstatt einem Integer-Arrays nur den Integer-Wert, erscheint in der Ausgabe ein Formatfehler:
Aufruf:
curl -k -u "very:secret" -H "Content-Type: application/json" -X POST -d "{ "objid" : 29, "category" : "C__CATS__PERSON_ASSIGNED_GROUPS", "data" : { "connected_object" : 35 , "contact" : 29 } }" http://localhost:4321/latest/category
{
"id": 0,
"success": false,
"message": "Internal error: There was an validation error"
}Auszug aus dem API-Log:
[2019-02-25 10:03:12 281845] DEBUG: Calculated model parameters based on method "cmdb.category.save"":
[
"category",
{
"object": 29,
"category": "C__CATS__PERSON_ASSIGNED_GROUPS",
"data": {
"contact": 29,
"connected_object": 35
},
"objID": 29,
"apikey": "xmreky8lf404k0oo",
"language": "en",
"option": "save"
}
]
[2019-02-25 10:03:12 281962] DEBUG: Prepare to run request...
[2019-02-25 10:03:12 283243] INFO: Method: save
[2019-02-25 10:03:12 288691] ERROR: An exception occured while processing request: -32603 Internal error: There was an validation error
{
"connected_object": "(object_browser) Property has to be an array."
}Object 29 ist die Person und Object 35 ist die Personengruppe.
Wie muss ein korrekter Aufruf aussehen?
Was ist bei der Verknüpfung von Personen, Personengrupppen und Organisationen zu beachten?Grüße
Oliver -
Das ist wohl das gleiche Problem wie hier:
Also: connected_object ist vom Typ Integer und Validierung ist auszuschalten.
-
Danke für den Link.
Die Lösung ( api.validation = 0 in den Expert Settings ) hat geholfen.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login