How to set First and Last name with /account/registration/?

Hi,

Im trying to figure out how to set First Name and Last Name when I create users using the account/registration/ endpoint.

Here is what Ive got:

EDX version:
3.2.14

POST URL:
…/user_api/v1/account/registration/

Data:
name=“Lorem Ipsum”
email="lorem@ipsum.com"
username=“L1”
password=“123456789”
honor_code=“true”

Result:
User Created and visible at
…/admin/auth/user/{userID}/change

Missing Name Fields:
Personal info > First Name
Personal info > Last Name

Correctly Set Name Field:
User Profile > Name

So basically, there are 2 different sections for name, one is set the other is not.

Also, where is this API Endpoint documented? I only found out about it after reading this post:

Hi @rhasan,

As Open edX is an international product, it is designed to work with names from around the world, which often don’t fall into the simple “First Name” + “Last Name” formula. Here’s a good article from the W3C showing examples of why that doesn’t work.

I believe that the “First Name” + “Last Name” fields you’re seeing exist in the Django admin and in the underlying data model, because they are provided by the framework that Open edX is built on, but Open edX itself doesn’t use those fields. So it’s safe/best to just leave them blank.

My recommendation is to change your business logic so that you only work with full names and don’t need the First Name / Last Name split. Alternatively, you can create your own API to get/set the first_name and last_name fields that exist in the database, but you’ll have to understand that those fields will be ignored by the platform and won’t be used by any of the standard APIs. You can use this extension point to add additional fields to the registration form, including “First name” and “Last name”, if required.

1 Like

Hello @rhasan,

This API endpoint is not documented yet but the upstream PR is in review state.

1 Like

@rhasan, there are many more additional fields that can be added to the registration form but are not enabled by default (code). To enable additional fields, you can configure them by specifying appropriate values for REGISTRATION_EXTRA_FIELDS either in the settings (via lms.yml) or in SiteConfiguration.

Though the Django User model has support for fields like ‘first name’, ‘last name’ etc., you will see that the platform stores these as key-value pairs in the UserProfile.meta field instead.

Some of these fields can be enabled and made visible in the Account Settings page by configuring the extended profile fields (code).