Hi,
I’m trying to use REST API to add a record in a table. PHP Project is basic. Users and dynamic user levels is activated. I can login with users, I can add records to table. But not through API.
With Postman, I do a login (see below) I get a JWT-tocken but when trying to add a record I get 401 Unauthorized.
POST: https://msgsys.domain.com/api/login
HEADERS
Content-Type=application/json
BODY
{
"username": "user",
"password": "password"
}
DECODED TOKEN
{
"iat": 1732407988,
"jti": "OWE5N2ExOGUtMzdhNC00MGFiLThmOWUtZjJhYTdlZDc2MzMx",
"iss": "msgsys.domain.com",
"nbf": 1732407988,
"exp": 1732408588,
"values": {
"username": "user",
"userid": "1",
"parentuserid": "",
"userlevel": -1,
"userprimarykey": 1,
"permission": 0
}
}
POST https://msgsys.domain.com/api/add/emails
HEADERS
Content-Type: application/json
Authorization: Bearer <JWT-token>
Accept: application/json
BODY
{
"subject": "Test Subject",
"from_address": "sender@example.com",
"to_address": "recipient@example.com",
"date": "2024-04-27 12:34:56",
"body": "This is a test email.",
"is_read": 0
}
RESULT: 401 Unauthorized
I’m probably doing something basic wrong. Any Ideas? (v2024.16)