Hi JM, I had a similar requirement a few weeks back. Pierre from Jembi helped with python scripting to convert all the user invites in csv to Json. It was then relatively easy to have multiple invites sent out in one command. If it helps, I have attached the script below and copied Pierre. He had mentioned working on this as a contribution to the community. Best regards, Busoye |
import requests import json import csv
resp = '' with open('invites.csv') as csvfile: invitereader=csv.reader(csvfile, delimiter=',') for row in invitereader: resp= '{"email": "'+row[0]+'","organisationUnits": [{"id": "'+row[1]+'" }],"userCredentials": {"username": "'+row[3]+'"},"groups": [{"id": "'+row[2]+'" }]},' print resp url = 'http://train.dhis.hisp.org/unisa/api/users/invite' headers = {'content-type': 'application/json'} response = requests.post(url, data=resp, auth=('admin', 'district'),headers=headers) print response
|
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp