##Example: Creating a user when the phone number must be valid *See Documentation
URL:
POST /api/v2/users.json
REQUEST:
curl -v -u {email_address}:{password} https://{subdomain}.zendesk.com/api/v2/users.json -H "Content-Type: application/json" -X POST -d '{"user": {"name": "Roger Wilco", "email": "roge@example.org", "phone": "+15551234567"}}'
RESPONSE: HTTP/1.1 201 Created
{
"user": {
"id": 1,
"url": "https://{subdomain}.zendesk.com/api/v2/users/1.json",
"name": "Roger Wilco",
"email": "roge@example.org",
"phone": "+15551234567"
}
}
URL:
POST /api/v2/users.json
REQUEST:
curl -v -u {email_address}:{password} https://{subdomain}.zendesk.com/api/v2/users.json -H "Content-Type: application/json" -X POST -d '{"user": {"name": "Roger Wilco", "email": "roge@example.org", "phone": "5551234567"}}'
RESPONSE: HTTP/1.1 422 Unprocessable Entity
{
"error": "RecordInvalid",
"description": "Record validation errors",
"details": {
"phone": {
"description": "Phone 5551234567 is not properly formatted",
"error": "InvalidFormat"
}
}
}
##Example: Creating a user when the phone number must be unique *Documentation
URL:
POST /api/v2/users.json
REQUEST:
curl -v -u {email_address}:{password} https://{subdomain}.zendesk.com/api/v2/users.json -H "Content-Type: application/json" -X POST -d '{"user": {"name": "Roger Wilco", "email": "roge@example.org", "phone": "+15551234567"}}'
RESPONSE: HTTP/1.1 201 Created
{
"user": {
"id": 1,
"url": "https://{subdomain}.zendesk.com/api/v2/users/1.json",
"name": "Roger Wilco",
"email": "roge@example.org",
"phone": "+15551234567",
"shared_phone_number": "false"
}
}
SUCCESS:
URL:
POST /api/v2/users.json
REQUEST:
curl -v -u {email_address}:{password} https://{subdomain}.zendesk.com/api/v2/users.json -H "Content-Type: application/json" -X POST -d '{"user": {"name": "Roger Wilco", "email": "roge2@example.org", "phone": "+15551234567"}}'
RESPONSE: HTTP/1.1 201 Created
{
"user": {
"id": 1,
"url": "https://{subdomain}.zendesk.com/api/v2/users/1.json",
"name": "Roger Wilco",
"email": "roge@example.org",
"phone": "+15551234567",
"shared_phone_number": "true"
}
}
##Example: Editing a phone number using the Users API *Documentation
####SUCCESS:
URL:
PUT /api/v2/users/1.json
REQUEST:
curl -v -u {email_address}:{password} https://{subdomain}.zendesk.com/api/v2/users/1.json -H "Content-Type: application/json" -X POST -d '{"user": {"name": "Roger Wilco", "email": "roge@example.org", "phone": "+15551234567"}}'
RESPONSE: HTTP/1.1 200 OK
{
"user": {
"id": 1,
"url": "https://{subdomain}.zendesk.com/api/v2/users/1.json",
"name": "Roger Wilco",
"email": "roge@example.org",
"phone": "+15551234567"
}
}
URL:
PUT /api/v2/users/1.json
REQUEST:
curl -v -u {email_address}:{password} https://{subdomain}.zendesk.com/api/v2/users/1.json -H "Content-Type: application/json" -X POST -d '{"user": {"name": "Roger Wilco", "email": "roge@example.org", "phone": "5551234567"}}'
RESPONSE: HTTP/1.1 422 Unprocessable Entity
{
"error": "RecordInvalid",
"description": "Record validation errors",
"details": {
"phone": {
"description": "Phone 555-123-4567 is not properly formatted",
"error": "InvalidFormat"
}
}
}
##Example: Editing a phone number using the User Identities API *Documentation
URL:
PUT api/v2/users/{user_id}/identities/{id}.json
REQUEST:
curl -v -u {email_address}:{password} https://{subdomain}.zendesk.com/api/v2/users/{user_id}/identities/{id}.json -H "Content-Type: application/json" -X PUT -d '{"identity": {"value": "+15551234567"}}'
RESPONSE: HTTP/1.1 200 OK
{
"identity": {
"url": "https://{subdomain}.zendesk.com/api/v2/users/1.json",
"id": 1,
"user_id": 1,
"type": "phone_number",
"value": "+15551234567",
"verified": true,
"primary": true
}
}
URL:
PUT api/v2/users/{user_id}/identities/{id}.json
REQUEST:
curl -v -u {email_address}:{password} https://{subdomain}.zendesk.com/api/v2/users/{user_id}/identities/{id}.json -H "Content-Type: application/json" -X PUT -d '{"identity": {"value": "5551234567"}}'
RESPONSE: HTTP/1.1 200 OK
{
"error": "RecordInvalid",
"description": "Record validation errors",
"details": {
"phone": {
"description": "Phone 5551234567 is not properly formatted",
"error": "InvalidFormat"
}
}
}
Hi, I suppose
phone
section has contains array, same as another errors type, am I right ?