Best Answer

Updating Additional Fields Via API

  • 24 August 2021
  • 6 replies
  • 854 views

Hi,

I am trying to create new users with additional fields in Docebo via the API. 

Currently I have a few additional fields that are not being set when I am creating a user. Is this possible ?

 

Thanks,
 

Ben

icon

Best answer by natemadel 24 August 2021, 21:54

View original

6 replies

Userlevel 5
Badge +1

Hey Ben, 

 

Yes, this is certainly doable. What are API are you using? manage/v1/user? manage/v1/user/batch?

 

Nate

Hi Nate, 

I am creating them one at a time, batch is not needed for this process. 

 

I am using POST to the following endpoint in a Nodejs Express server.

/manage/v1/user

with the following json object.

{

"email": visitor.email,"password": "*********","firstname":  visitor.firstName,"lastname": visitor.lastName,"expiration":  visitor.orientationExpiryDate,"additional_fields": {  "field_9" : visitor.jobTitle,  "field_15": visitor.phone,  "field_18": visitor.visitorType,  "field_22": visitor.companyName,}

}

I also tried :

{

"email": visitor.email,"password": "*********","firstname":  visitor.firstName,"lastname": visitor.lastName,"expiration":  visitor.orientationExpiryDate,"field_9" : visitor.jobTitle,"field_15": visitor.phone,"field_18": visitor.visitorType,"field_22": visitor.companyName,}

When the user is created:  email, password, firstname, lastname, expiration all get added for the user for both the above json objects, but none of the additional fields are populated. I assume its an issue with the object i’m sending over? 

 

The “additional” field numbers I grabbed from the GET /manage/v1/user just looking at the object that was returned there.

 

Thanks,


Ben

Userlevel 5
Badge +1

Gotcha. I think you need to drop the “field” prefixes, give this one a go and let me know:

 

 {
"email":"visitor.email",
"password":"*********",
"firstname":"visitor.firstName",
"lastname":"visitor.lastName",
"expiration":"visitor.orientationExpiryDate",
"additional_fields":{
"9":"visitor.jobTitle",
"15":"visitor.phone",
"18":"visitor.visitorType",
"22":"visitor.companyName"
}
}

 

Amazing, Thank you Nate! That worked!

 

Just another quick one, if I am trying to populate additional field of type dropdown, does it need an id for that field or is it just matching the string value ?

 

Thanks,

 

Ben

Userlevel 5
Badge +1

You bet. For the dropdown, it will want the ID of the dropdown option (still quotated though). Manage/v1/user/batch, while probably overkill for one off creations, does accept the friendly values for dropdowns if you’d rather not trouble with it. 

 

Nate

The reply above was very helpful, but I had trouble setting a ‘yesno’ type additional user field with the api.  I tried all the combinations I could think of then realized that a ‘yesno’ type field might actually be a dropdown. Therefore, this works (assuming the additional field is field 1):

For Yes:

"additional_fields": {"1": "1"}

For No:

"additional_fields": {"1": "2"}

Hope this saves someone some frustration.

Jon

 

 

Reply