1

Topic: Can't create user with requests library in python

==== Required information ====
- iRedMail version:
- Store mail accounts in which backend (LDAP/MySQL/PGSQL):
- Linux/BSD distribution name and version:
- Related log if you're reporting an issue:
======== Required information ====
- iRedMail version: 0.8.7
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL
- Linux/BSD distribution name and version: CentOS 6.5
- Related log if you're reporting an issue:
====
Hi all,

I want to create user by using request library in python. My code likes that:

import requests
import json

url = 'https://mail.lazada.com/iredadmin/create/user/mx.lazada.com'
headers = {'Content-Type': 'application/json'}
payload = {'csrf_token': 'aaa', 'username': 'c', 'domainName': 'mx.lazada.com', 'newpw': 'xxx', 'confirmpw': 'xxx', 'cn': 'c', 'mailQuota': '10'}
r = s.post(url, data=json.dumps(payload), verify=False)

Return code is 200 but I don't see record is updated in DB.

So could anybody help me?

Thanks a lot.

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Can't create user with requests library in python

If action/operation was completed without error, it usually redirect to a new URL with certain query parameter (?msg=xxx).

for example:

* https://[server]/iredadmin/...?msg=CREATED
* https://[server]/iredadmin/...?msg=UPDATED
* https://[server]/iredadmin/...?msg=[REASON]

message CREATED, UPDATED means account was created or account profile was updated without error. otherwise it will be detailed error message.

Also, you must login as domain admin first.