Trying to add new OrgApplications
Trying to add Org Applications to an existing user. Getting exception message The JsonPatchDocument was malformed and could not be parsed. I've tried adding one OrgApp and with POSTing changes to this to add, neither has worked. Below is the latest attempt (*it's probably a syntax error and I'm not seeing it....)
Call: Patch https://tulsalibrary.teamdynamix.com/SBTDWebApi/api/people/f544c51d-4e75-ef11-991b-85f92b4cb377
Body:
{
"op": "add",
"path": "/OrgApplications",
"value": [
{
"ID": 102,
"SecurityRoleID": "b73cf2d0-68b5-4947-aa49-5edf44e024ad"
},
{
"ID": 103,
"SecurityRoleID": "249f0e9e-dcbc-4856-b961-50ef0f61e693"
},
{
"ID": 104,
"SecurityRoleID": "28f192ff-d590-4e68-9e7d-44296a0e3917"
}
]
}
Returns:
{
"ID": -1,
"Message": "patch must not be null. Errors:\r\n* Exception Message: The JsonPatchDocument was malformed and could not be parsed."
}
Answer (1)
Your PATCH call body *does* need to be an array. It should be an array of possible opperations, in this case just the one operation to add the orgapps.
Sincerely,
Mark Sayers
Sr Support Consultant, CS
Body:
{
[
"op": "add",
"path": "/OrgApplications",
"value": [
{
"ID": 103,
"SecurityRoleID": "249f0e9e-dcbc-4856-b961-50ef0f61e693"
},
{
"ID": 104,
"SecurityRoleID": "28f192ff-d590-4e68-9e7d-44296a0e3917"
}
]
]
}
Return:
{
"ID": -1,
"Message": "patch must not be null. Errors:\r\n* Exception Message: The JsonPatchDocument was malformed and could not be parsed."
} - Scott Williamson Fri 9/20/24 1:24 PM
[
{
"op": "add",
"path": "/OrgApplications",
"value": [
{
"ID": 103,
"SecurityRoleID": "249f0e9e-dcbc-4856-b961-50ef0f61e693"
},
{
"ID": 104,
"SecurityRoleID": "28f192ff-d590-4e68-9e7d-44296a0e3917"
}
]
}
]
where the first and last [ ] characters indicate the *entire* body is going to consist of an array. That array can have one or more "op" objects to update different paths/properties on a person's account. Then the value of that OrgApplications set for that user would be the two objects showing the app ID of the desired app and the security role ID of the desired role you want to set. - Mark Sayers Fri 9/20/24 1:46 PM
Only thing to add: Tried the above code and got "Could not edit user: The primary Client Portal Application specified is missing from the provided list of organization applications."
When I added back the staff portal:
[
{
"op": "add",
"path": "/OrgApplications",
"value": [
{
"ID":102,
"SecurityRoleID": "b73cf2d0-68b5-4947-aa49-5edf44e024ad"
},
{
"ID": 103,
"SecurityRoleID": "249f0e9e-dcbc-4856-b961-50ef0f61e693"
},
{
"ID": 104,
"SecurityRoleID": "28f192ff-d590-4e68-9e7d-44296a0e3917"
}
]
}
]
- the patch ran successfully. - Scott Williamson Fri 9/20/24 2:14 PM