Client Data Changes
How to follow this chapter
Inputs: userId, a token permitted to update that client, and the fields the client wants to change.
Steps and expected result: Send only the intended updates. A successful response confirms the update request; read the client again when your UI needs the refreshed values.
Alternative or later actions: Changing personal details and changing address are separate recipes; use the one matching the requested change.
DTO source: CountryOutputModel
Variables assigned in an earlier block are reused by later blocks. Client-entered values come from your UI; keep identifiers and lookup results in the current client context. Do not create a fresh context between steps.
The snippets use shared helper classes. See Shared helper classes: complete C# and Java source before copying an example.
Before you start: The userId and a CLIENT or ADMIN token authorized to update it. The fragment variables represent values collected from the client.
Keep for the next step: Updated client data. Complete any additional OTP verification or identity-document steps required for the requested change.
There are several API endpoints for updating client data.
In this section, we will look at only the most commonly used ones.
For the others, please see the /api/v1/users endpoint.
Attention
For the client-data update endpoint shown here, fields omitted from jsonPayload or set to null remain unchanged. A non-null value requests a change and is subject to validation. This endpoint does not provide a general mechanism to clear every field. Address and other dedicated endpoints have their own schemas.
Changing client data
Inputs: userId, authorized token and intended personal-data changes.
Action: Submit the update payload.
Keep / expected result: Handle any validation response before updating the UI.
Action: Submit the update payload.
Keep / expected result: Handle any validation response before updating the UI.
Provide only the fields the client intends to change. The following example illustrates the field names; omitted or null values remain unchanged. If the API requires an identity document or contact-change OTP, obtain it using the relevant workflow before retrying the update:
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
// Assuming this is our client ID
// userId is the identifier returned by registration.
var clientUpdateInputModel = new
{
Name = name,
Surname = surname,
Email = email,
PhoneNumberPrefix = phoneNumberPrefix,
PhoneNumberNumber = phoneNumberNumber,
BirthDate = birthDate,
GenderId = genderId,
LanguageId = languageId,
Nationality1Id = nationalityId,
DeliverTaxStatement = deliverTaxStatement,
PensionSituationId = pensionSituationId
};
var clientUpdateInputModelAsString = JsonConvert.SerializeObject(clientUpdateInputModel);
using var clientUpdateContent = new MultipartFormDataContent();
clientUpdateContent.Add(new StringContent(clientUpdateInputModelAsString, Encoding.UTF8, "application/json"), "jsonPayload");
(await httpClient.PutAsync($"api/v1/users/user-id/{userId}", clientUpdateContent)).EnsureSuccessStatusCode();
// Assuming this is our client ID
// userId is the identifier returned by registration.
JsonObject clientChangeDataPayload = new JsonObject();
clientChangeDataPayload.addProperty("Name", name);
clientChangeDataPayload.addProperty("Surname", surname);
clientChangeDataPayload.addProperty("Email", email);
clientChangeDataPayload.addProperty("PhoneNumberPrefix", phoneNumberPrefix);
clientChangeDataPayload.addProperty("PhoneNumberNumber", phoneNumberNumber);
clientChangeDataPayload.addProperty("BirthDate", birthDate);
clientChangeDataPayload.addProperty("GenderId", genderId);
clientChangeDataPayload.addProperty("LanguageId", languageId);
clientChangeDataPayload.addProperty("Nationality1Id", nationalityId);
clientChangeDataPayload.addProperty("DeliverTaxStatement", deliverTaxStatement);
clientChangeDataPayload.addProperty("PensionSituationId", pensionSituationId);
MultiPartBodyPublisher multipartClientChangeOrderBody = new MultiPartBodyPublisher()
.addPart("jsonPayload", clientChangeDataPayload.toString());
// Add the required identification file as userIdentities when the API requires it.
HttpRequest clientDataChangeRequest = HttpRequest.newBuilder()
.timeout(Duration.ofMinutes(1))
.uri(Settings.wmsUri("users/user-id/" + userId))
.header("Accept-Language", "de-DE")
.header("Authorization", "Bearer " + accessToken)
.header("Content-Type", "multipart/form-data; boundary=" + multipartClientChangeOrderBody.getBoundary())
.PUT(multipartClientChangeOrderBody.build())
.build();
var response = httpClient.send(clientDataChangeRequest, BodyHandlers.ofString());
Api.requireSuccess(response);
Changing address
Inputs: userId, address fields and the resolved country ID.
Action: Submit the address change.
Keep / expected result: Read the client again if the UI needs the updated server values.
Action: Submit the address change.
Keep / expected result: Read the client again if the UI needs the updated server values.
The following example shows how to change the client’s address:
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
var userAddressInputModel = new
{
Street = street,
StreetNr = streetNr,
City = city,
CountryId = countryId,
Zip = zip
};
// userId is the identifier returned by registration.
var userAddressInputModelAsString = JsonConvert.SerializeObject(userAddressInputModel);
(await httpClient.PutAsync($"api/v1/users/update-address/user-id/{userId}", new StringContent(userAddressInputModelAsString, Encoding.UTF8, "application/json"))).EnsureSuccessStatusCode();
HttpRequest countryRequest = HttpRequest.newBuilder()
.timeout(Duration.ofMinutes(1))
.uri(Settings.wmsUri("countries/code/FR"))
.header("Accept-Language", "de-DE")
.header("Authorization", "Bearer " + Settings.GUEST_TOKEN) // or CLIENT/ADMIN ACCESS TOKEN
.header("Content-Type", "application/json")
.build();
var response = httpClient.send(countryRequest, BodyHandlers.ofString());
Api.requireSuccess(response);
CountryOutputModel countryObj = new Gson().fromJson(response.body(), CountryOutputModel.class);
var countryId = countryObj.Id;
// Assuming this is our client ID
// userId is the identifier returned by registration.
JsonObject newAddressPayload = new JsonObject();
newAddressPayload.addProperty("Street", street);
newAddressPayload.addProperty("StreetNr", streetNr);
newAddressPayload.addProperty("City", city);
newAddressPayload.addProperty("CountryId", countryId);
newAddressPayload.addProperty("Zip", zip);
HttpRequest theRequest = HttpRequest.newBuilder()
.timeout(Duration.ofMinutes(1))
.uri(Settings.wmsUri("users/update-address/user-id/" + userId))
.header("Accept-Language", "de-DE")
.header("Authorization", "Bearer " + accessToken) // or CLIENT ACCESS TOKEN
.header("Content-Type", "application/json")
.PUT(HttpRequest.BodyPublishers.ofString(newAddressPayload.toString()))
.build();
response = httpClient.send(theRequest, BodyHandlers.ofString());
Api.requireSuccess(response);