Recent searches
No recent searches
Error When Creating Users with Phone Numbers in Specific Zendesk Instances
Posted Nov 13, 2024
I am a developer working on a Zendesk app that we provide to our customers. In this post, I would like to ask about an issue occurring in one of our customer's environments.
We have a function that creates a user based on a given phone number and returns the user ID. Here is an example of the function:
export const createNewUser = async (phoneNumber: string) => {
const data: ZendeskApiUserCreate = {
user: {
name: phoneNumber,
phone: phoneNumber,
verified: true,
},
};
const options: ZendeskApiOptions = {
url: "/api/v2/users.json",
type: "POST",
contentType: "application/json",
data: JSON.stringify(data),
};
const response = await client.request<ZendeskApiUser>(options);
return response?.user?.id;
};
When passing a string like 0901234567
to the phoneNumber
parameter of this createNewUser
function, it works fine in most Zendesk instances. However, in a specific customer's instance, we encounter the following error:
{
“readyState”: 4,
“responseJSON”: {
“error”: “RecordInvalid”,
“description”: “Record validation errors”,
“details”: {
“phone”: [
{
“description”: “Phone 09012345678のフォーマットを確認してください。正しい国際電話番号E.164は、国番号、通常は地域番号、および契約者番号から構成されます。例: +1 (555) 123-4567。“,
“error”: “InvalidFormat”
}
]
}
},
“responseText”: “{\“error\“:\“RecordInvalid\“,\“description\“:\“Record validation errors\“,\“details\“:{\“phone\“:[{\“description\“:\“Phone 09012345678のフォーマットを確認してください。正しい国際電話番号E.164は、国番号、通常は地域番号、および契約者番号から構成されます。例: +1 (555) 123-4567。\“,\“error\“:\“InvalidFormat\“}]}}“,
“status”: 422,
“statusText”: “error”
}
Interestingly, in my development instance (d3v environment), I was able to create a user even when using a phone number string like "!-'~'()$%&_=^|[]{};:,<>@"
without encountering any errors.
Is this problem caused by a difference in some specific configuration of the customer's instance? Or could there be another possible reason for this behavior?
Any insights would be greatly appreciated. Thank you in advance for your help.
0
1 comment
Christopher Kennedy
As the error message notes, we're expecting the phone number to be E.164 format. This format becomes required when the account has phone number validation enabled.
0