Recipes
Upload address book with incorrect data
1. Use a `contacts` parameter to set an array of contact hashes
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
-d '{
"contacts": [
{
"name": "Alex"
},
{
"phone": "45645645666"
},
{
"name": "",
"phone": "456456456"
}
],
"udid": "2222E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
}' \
https://api.quickblox.com/address_book.json
2. Set a `name` and `phone` of the contact as separate arrays
Note that it’s incorrect to set a name
separately from a phone
. curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
-d '{
"contacts": [
{
"name": "Alex"
},
{
"phone": "45645645666"
},
{
"name": "",
"phone": "456456456"
}
],
"udid": "2222E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
}' \
https://api.quickblox.com/address_book.json
3. Set a `name` as an empty string
Note that a name is limited to a number of signs. Min: 1 . Max: 255 . curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
-d '{
"contacts": [
{
"name": "Alex"
},
{
"phone": "45645645666"
},
{
"name": "",
"phone": "456456456"
}
],
"udid": "2222E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
}' \
https://api.quickblox.com/address_book.json
4. Set an incorrect phone length
Note that a phone is limited to a number of signs. Min: 10 . Max: 15 . curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
-d '{
"contacts": [
{
"name": "Alex"
},
{
"phone": "45645645666"
},
{
"name": "",
"phone": "456456456"
}
],
"udid": "2222E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
}' \
https://api.quickblox.com/address_book.json
5. As a result, the API returns a `200` status response specifying that the data were set incorreclty.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
-d '{
"contacts": [
{
"name": "Alex"
},
{
"phone": "45645645666"
},
{
"name": "",
"phone": "456456456"
}
],
"udid": "2222E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
}' \
https://api.quickblox.com/address_book.json
1. Use a `contacts` parameter to set an array of contact hashes
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
-d '{
"contacts": [
{
"name": "Mike Howard",
"phone": "463571393241"
},
{
"name": "Morgan Fuller",
"phone": "65021272571"
}
],
"udid": "A337E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
}' \
https://api.quickblox.com/address_book.json
2. Set a name of the contact
Use a name
parameter to set the name of the contact. curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
-d '{
"contacts": [
{
"name": "Mike Howard",
"phone": "463571393241"
},
{
"name": "Morgan Fuller",
"phone": "65021272571"
}
],
"udid": "A337E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
}' \
https://api.quickblox.com/address_book.json
3. Set a phone of the contact
Use a phone
parameter to set a phone of the contact. curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
-d '{
"contacts": [
{
"name": "Mike Howard",
"phone": "463571393241"
},
{
"name": "Morgan Fuller",
"phone": "65021272571"
}
],
"udid": "A337E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
}' \
https://api.quickblox.com/address_book.json
4. As a result, the API returns a `200` status response specifying that the contacts were uploaded.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
-d '{
"contacts": [
{
"name": "Mike Howard",
"phone": "463571393241"
},
{
"name": "Morgan Fuller",
"phone": "65021272571"
}
],
"udid": "A337E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
}' \
https://api.quickblox.com/address_book.json
This API allows you to do following things:
Upload new address book.
Replace old address book with a new one.
Add/delete individual contacts.
Update existing contacts.
Body Parameters
Contains an array of contact objects. Each contact can contain 3 keys - phone
, name
, and destroy
. Contact phone. Min: 10. Max: 15.
Contact name. Required only for create/update. Min: 1. Max: 255.
Used in a case of a contact destroy. Set destroy=1
to apply.
Defines force rewrite mode. Set force=1
to apply, then all previous contacts for the device context
will be replaced by new ones.
User’s device identifier. If specified, all operations will be in this context. Max. length is 64 symbols.
If the device identifier is not specified, it means that a user has one global address book across all
their devices.
A user session token. See
Authentication page to learn more about the session token.
Responses
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
-d '{
"contacts": [
{
"name": "Mike Howard",
"phone": "463571393241"
},
{
"name": "Morgan Fuller",
"phone": "65021272571"
}
],
"udid": "A337E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
}' \
https://api.quickblox.com/address_book.json
{
"created" : 2 ,
"updated" : 0 ,
"deleted" : 0
}