1

Topic: 404 Error when creating Mail User via API

==== Required information ====
- iRedMail version (check /etc/iredmail-release): v0.9.5-1
- Linux/BSD distribution name and version: CentOS 6.8
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): LDAP
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? Yes
- Related log if you're reporting an issue:
====

I have updated the settings.py file to enable the API and rebooted the server...

Ran the command below to create a user via an API call and received a 404 error:

c:\cURL>curl -X POST -i -b cookie.txt -k -d "cn=Some Company&mailQuota=1024" https://mx1.mydomain.com/api/user/0000@ … domain.com
HTTP/1.1 404 Not Found
Server: nginx
Date: Mon, 31 Oct 2016 21:52:49 GMT
Content-Type: text/html
Content-Length: 162
Connection: keep-alive

----

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

2

Re: 404 Error when creating Mail User via API

Sorry about this trouble. Which version of iRedAdmin-Pro are you running?

3

Re: 404 Error when creating Mail User via API

iRedAdmin-Pro    v2.6.1 (LDAP)

4

Re: 404 Error when creating Mail User via API

You missed '/iredadmin' before '/api/' in URL.
https://<server>/iredadmin/api/user/<mail>

5

Re: 404 Error when creating Mail User via API

Thanks for the help. However when I create a mail user with this POST, the user is created with the password, language and quota set, but the name is not set. The display name field is empty.

What I sent:

c:\cURL>curl -X POST -i -b cookie.txt -k -d "name=Some Company&password=#A123456&language-en-us&quota=512" https://mx1.mydomain.com/iredadmin/api/ … domain.com

6

Re: 404 Error when creating Mail User via API

With iRedAdmin-Pro-LDAP-2.6.1, please use "cn" instead of "name". Sorry about the confusion.

In upcoming iRedAdmin-Pro release, several parameter names have been changed:

- old: `cn` -> new: `name`
- old: `mailQuota` -> new: `quota`
- old: `preferredLanguage` -> new: `language`

7

Re: 404 Error when creating Mail User via API

Thanks for the guidance. I have another issue. After importing ~494 the API Create Mail User function starts returning the following error. Ran the import twice and it happened at exactly the same place.

c:\cURL>c:\cURL\curl -X POST -i -b cookie.txt -k -d "cn=SPG Inc.&password=#A123456&language=en_US&quota=128" https://mx1.mydomain.com/iredadmin/api/ … domain.com
HTTP/1.1 200 OK
Server: nginx
Date: Tue, 01 Nov 2016 23:24:16 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Set-Cookie: iRedAdmin-Pro-ldap=e700aae0dc8b81265beaac8b5d99f058033200ec; Path=/iredadmin/; httponly

{"msg": "{'info': 'index generation failed', 'desc': 'Other (e.g., implementation specific) error'}", "success": false}

8

Re: 404 Error when creating Mail User via API

Do you have setting 'maxsize' in /etc/openldap/slapd.conf? If not, please add it after 'database xxx' line like below:

maxsize     2147483648

Then restart OpenLDAP service.

9

Re: 404 Error when creating Mail User via API

Thank you. That worked like a charm...