[SOLVED] API Create user

General discussion of Mantis.

Moderators: Developer, Contributor

Post Reply
castris
Posts: 6
Joined: 29 May 2023, 06:22

[SOLVED] API Create user

Post by castris »

I'm trying to use the api from Postman on a Mantis 2.25.7 to create a user with specific data.

Your example with dummy data

Code: Select all

curl --location 'https://my.domain.tld/gmao/api/rest/users/' \
--header 'Authorization: 6H6R8AKuKUkUkUkUkUDP5Vn1fZ' \
--header 'Content-Type: text/plain' \
--header 'Cookie: MANTIS_PROJECT_COOKIE=0; PHPSESSID=e76dc8f6bdd28031eda749424ef5932a' \
--data-raw '{
   "username": "testuser",
   "password": "p@ssw0rd",
   "real_name": "Victor Boctor",
   "email": "victor@yet-another-domain.com",
   "access_level": { "name": "updater" },
   "enabled": false,
   "protected": false
}'
The result:

Code: Select all

400 Invalid request body or format
If use

Code: Select all

curl --location 'https://my.domain.tld/gmao/api/rest/users/' \
--header 'Authorization: 6H6R8AKuKUkUkUkUkUDP5Vn1fZ' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Cookie: MANTIS_PROJECT_COOKIE=0; PHPSESSID=e76dc8f6bdd28031eda749424ef5932a' \
--data-urlencode 'username=CoreSuperAdmin' \
--data-urlencode 'password=PaSsW0OrDa' \
--data-urlencode 'real_name=CoreSuperAdmin' \
--data-urlencode 'email=superadmin@mail.com'
Work... But I can't 0r I don't know how to send access_level

Appreciate help.
Last edited by castris on 30 May 2023, 06:35, edited 1 time in total.
castris
Posts: 6
Joined: 29 May 2023, 06:22

Re: API Create user

Post by castris »

After downloading postman collection I see my error

```curl
curl --location 'https://my.domaon.tld/gmao/api/rest/users/' \
--header 'Authorization: oSuMFbvFTiokeToken2WXNIyxzaM' \
--header 'Content-Type: application/json' \
--header 'Cookie: MANTIS_PROJECT_COOKIE=0; PHPSESSID=e76dc8f6bdd28031eda749424ef5932a' \
--data-raw '{
"username": "borrame2",
"password": "r87PaSsW0RdCXz",
"real_name": "borrame2 realname",
"email": "borrame2@example2.com",
"access_level":
{
"name": "developer"
},
"enabled": true,
"protected": false
}'
```
Post Reply