import requests
import json
# List of the leads you want to import
# The first item is User ID, the second is email
users = [
(123, 'mail1@gmail.com'),
(456, 'mail2@gmail.com'),
]
count = 0
auth_token = 'XXX' # TODO: add your auth_token
for u in users:
#lead properties
user_id = u[0]
email = u[1]
# Formed address
# Method documentation:
url = 'http://api.dashly.io/v1/users/%d/props?auth_token=%s'
url = url % (user_id, auth_token)
# The only one operation is to set an email
operations = [{"op": "update_or_create", "key": "$email", "value": email}]
operations = json.dumps(operations)
# Everything is ready, make the request, in accordance with parameters described in the documentation
requests.post(url, data={'operations': operations, 'by_user_id': True, 'app': '$self_app'})
# To monitor progress
count += 1
print(count, len(users))