Setting custom attributes via the web API

I'm trying to update user's custom attribute information in the system using the API. According to the API this should be do able simply by sending a list of attributes with the attribute name and it's order. I infer that I must also send the TextValue if I want to set the text value of the property. I'm trying that and the result is that all the attributes for a user get erased. Here is my data payload:

 

{
   "guid":"b081401a-9455-49-13aa94530446",
   "username":"",
   "active":"True",
   "FirstName":"",
   "LastName":"",
   "PrimaryEmail":"@usd.edu",
   "AlertEmail":"@usd.edu",
   "AlternateEmail":"",
   "Title":"Systems Software Specialist",
   "PrimaryPhone":"",
   "WorkPhone":"",
   "WorkAddress":"579 Robert L Slagle Hall",
   "WorkCity":"Vermillion",
   "WorkState":"SD",
   "WorkZip":"57069     ",
   "ExternalID":"",
   "HomePhone":"",
   "DefaultPriorityID":20,
   "DefaultAccountID":80,
   "typeId":"1",
   "TZID":4,
   "Company":"University of South Dakota",
   "AuthenticationProviderID":"3",
   "SecurityRoleId":"",
   "IsActive":"True",
   "IsEmployee":"True",
   "WorkableHours":"8",
   "IsCapacityManaged":"True",
   "ReportsToUID":"91e63e1c-b6f9-4679-84b6-590bcc86e1d4",
   "ShouldReportTime":"True",
   "ResourcePoolID":"7",
   "ReportTimeAfterDate":"6/18/2011 12:00:00 AM",
   "EndDate":"12/27/2019 12:00:00 PM",
   "CostRate":"50.0000",
   "DefaultRate":"50.0000",
   "alternateID":"",
   "Attributes":[
      {
         "ID":651,
         "Name":"Primary Affiliation",
         "Order":1,
         "ValueText":"Staff"
      }
   ]
}
 
Redacted sensitive information of course. Everything looks right but clearly it is still upset over something. The ID I pass here is what I got from the database when I queried:
 
SELECT * FROM [TeamDynamix].[dbo].[Attributes] WHERE att_name = 'Primary Affiliation'
 
What am I doing wrong here? What am I missing?
Tags 10-0 webapi custom-attributes
Asked by Toben Archer on Fri 4/27/18 5:42 PM
Sign In to leave feedback or contribute an answer

Answer (1)

This answer has been marked as the accepted answer
Matt Sayers Fri 4/27/18 10:35 PM

Hi Toben,

You'll actually want to set the Value property of the attribute, not ValueText. Additionally, you don't have to pass the Name or the Order property for each custom attribute on the user as it only uses ID and Value for the save.

Try it with a JSON payload something like this:
{
.....
"Attributes": [
  {
    "ID":651,
    "Value":"Staff"
]
.....
}


Finally, remember that the User edit endpoint does not accept PATCH calls or only partially filled out user objects. It expects a fully inflated user object with all of the expected properties set or you may cause accidental data loss.

Let me know if this helps!

No feedback