User
In this section you can find, examples of HTTP requests and responses for managing users
Create New
# Http requestPOST
http://localhost:8080/api/user
HTTP/1.1
Request
Authorization : Bearer {jwt.token}
Content-Type : application/json
{
"email": "test@gmail.com",
"password":"1234",
"userGroup": 2,
"userDetail": {
"name": "Unit",
"surname": "Test",
"phoneNumber": "+99830 302 03 23",
"department": "Tester",
"organisation": "TestGmbH",
"salutation": "Salutations"
}
}
Response
Success:
userGroup.icon could be null
or can hold a link
if userGroup icon is set.
userDetail.profilePicture will be null becouse image will be set by another request.
{
"enhanceId": 14,
"email": "test1@gmail.com",
"userGroup": [
{
"enhanceId": 38,
"role": "USER_ROLE",
"description": "User role",
"icon": null,
"components": [
{
"enhanceId": 1,
"name": "TRANSACTION",
"description": "Transaction description",
"permissions": [
"READ",
"DELETE",
"CREATE",
"UPDATE"
]
},
{
"enhanceId": 2,
"name": "CONNECTOR",
"description": "Connector description",
"permissions": [
"READ",
"CREATE"
]
}
]
}
],
"userDetail": {
"name": "John",
"surname": "Doe",
"phoneNumber": "+99830 302 03 23",
"department": "Manager",
"organisation": "Org",
"salutation": "I freez you!",
"profilePicture": null,
"requestTime": null
}
}
Error:
{
"timestamp" : "2018-05-24T12:44:26.295+0000",
"status" : 500,
"error" : "Internal Error",
"message" : "CREATION_ERROR",
"success" : "false",
"path" : "/api/user"
}
Upload Profile Picture of User
Before sending request for uploding User Profile Picture, you have to send request for Creating User! After this opertaion you can send request for uploading profile picture.
# Http request for picture uploadPOST
http://localhost:8080/api/storage/profilePicture
HTTP/1.1
Authorization : Bearer {jwt.token}
Content-Type : multipart/form-data
After user has been created, you will get an email of user.
|
|
---|---|
Key |
Value |
file |
{ uploaded file } |
{ user email } |
If error will occur you will get response
.
Error:
Internal Error 500
{
"timestamp" : "2018-05-24T12:44:26.295+0000",
"status" : 500,
"error" : "Internal Error",
"message" : "WRONG_FORMAT",
"success" : "false",
"path" : "/api/storage/{profilePicture}"
}
Get All
# Http requestGET
http://localhost:8080/api/user/all
HTTP/1.1
Request
Authorization : Bearer {jwt.token}
Content-Type : application/json
Response
Success:
{
"_embedded" : {
"userResources" : [
{
"enhanceId" : 1,
"email" : "admin@gmail.com",
"userGroup" : [
{
"name" : "ROLE_ADMIN",
"description" : "Administrator role",
"icon" : "http://localhost/resource/icon_hat.png",
"components" : [
{
"name" : "TRANSACTION",
"description" : "Manages transactions",
"permissions" : [
"READ",
"DELETE",
"CREATE",
"UPDATE"
]
},
{
"name" : "USER",
"description" : "Gets component for user management",
"permissions" : [
"READ",
"CREATE"
]
}
]
}
],
"userDetail" : {
"name" : "Unit",
"surname" : "Test",
"phoneNumber" : "+99830 302 03 24",
"department" : "Tester",
"organisation" : "TestGmbH",
"salutation" : "Salutations",
"profilePicture" : "http://localhost/resource/profile.png",
"requestTime" : "2018-10-05T03:24:59.000+0000"
}
},
{
"enhanceId": 2,
"email": "user@gmail.com",
"userGroup": [
{
"enhanceId" : 2,
"name" : "ROLE_USER",
"description" : "Administrator role",
"icon" : "http://localhost/resource/icon_hat.png"
"components" : [
{
"name" : "USER",
"description" : "Gets component for user management",
"permissions" : [
"READ",
"CREATE"
]
}
]
}
],
"userDetail" : {
"name" : "User",
"surname" : "UserName",
"phoneNumber" : "+99830 302 03 23",
"department" : "Users",
"organisation" : "Locta",
"salutation" : "Salutations",
"profilePicture" : "http://localhost/resource/profile.png",
"requestTime" : "2018-10-05T03:24:59.000+0000"
}
}
]
}
}
Error:
{
"timestamp" : "2018-05-24T12:44:26.295+0000",
"status" : 500,
"error" : "Authorization error",
"message" : "ACCESS_DENIED",
"success" : "false",
"path" : "/api/user/all"
}
Get One
# Http requestGET
http://localhost:8080/api/user/{userId}
HTTP/1.1
Request
Authorization : Bearer {jwt.token}
Content-Type : application/json
Response
Success:
{
"enhanceId" : 2,
"email" : "user@gmail.com",
"userGroup" : [
{
"enhanceId" : 2,
"name" : "ROLE_USER",
"description" : "Administrator role",
"icon" : "http://localhost/resource/icon.png",
"components" : [
{
"enhanceId" : 1,
"name" : "USER",
"description" : "Gets component for user management",
"permissions" : [
"READ",
"CREATE"
]
}
]
}
],
"userDetail" : {
"name" : "User",
"surname" : "UserName",
"phoneNumber" : "+99830 302 03 23",
"department" : "Users",
"organisation" : "Locta",
"salutation" : "Salutations",
"profilePicture" : "http://localhost/resource/profile.png",
"requestTime" : "180092832"
}
}
Error:
{
"timestamp" : "2018-05-24T12:44:26.295+0000",
"status" : 500,
"error" : "Wrong header credentials"
"message" : "ACCESS_DENIED",
"success" : "false",
"path" : "/api/user/{userId}"
}
Change Password
# Http requestPUT
http://localhost:8080/api/user/{userId}/password
HTTP/1.1
Request
Authorization : Bearer {jwt.token}
Content-Type : application/json
{
"enhanceId" : 1,
"email" : "test@gmail.com",
"password" : "new password"
}
Response
Success:
200 OK
Error:
500 Internal Error
{
"timestamp" : "2018-05-24T12:44:26.295+0000",
"status" : 500,
"error" : "Token has been expired"
"message" : "TOKEN_EXPIRED",
"success" : "false",
"path" : "/api/user/{userId}/password"
}
Change Detail
# Http requestPUT
http://localhost:8080/api/user/{userId}/userDetail
HTTP/1.1
Request
profilePicture
should be set to null
.
Authorization : Bearer {jwt.token}
Content-Type : application/json
{
"enhanceId": 1,
"name": "Unit",
"surname": "Test",
"phoneNumber": "+99830 302 03 24",
"department": "Tester",
"organisation": "TestGmbH",
"salutation": "Salutations",
"profilePicture" : null,
"requestTime" : "180092832"
}
if you want to update profilePicture
you have to send following request:
# Http request for picture uploadPOST
http://localhost:8080/api/storage/profilePicture
HTTP/1.1
Authorization : Bearer {jwt.token}
Content-Type : multipart/form-data
|
|
---|---|
Key |
Value |
file |
{ uploaded file } |
{ user email } |
Response
Success:
201 Created
{
"enhanceId": 1,
"name": "John",
"surname": "Doe",
"phoneNumber": "+99830 302 03 23",
"department": "Manager Admin test",
"organisation": "Mason",
"salutation": "I freez you!",
"profilePicture": "http://localhost:8080/api/storage/files/d93ea7c0-dd24-4ea9-b40f-cbb43a9b3e21.jpg",
"requestTime": "2018-07-05T08:10:42.000+0000"
}
Error:
{
"timestamp" : "2018-05-24T12:44:26.295+0000",
"status" : 500,
"error" : {
"message" : "Forbidden"
},
"success" : "false",
"path" : "/api/user/storage/profilePicture"
}
Change User Group
# Http requestPUT
http://localhost:8080/api/user/{userId}/userGroup
HTTP/1.1
Request
For changing user group, you have to put in user.userGroup
an enhanceId of UserGroup.
Get a list of all user_group you can find via request: {hostname}/api/userGroup/all
Authorization : Bearer {jwt.token}
Content-Type : application/json
{
"enhanceId":"3",
"userGroup": 1
}
Response
Success:
201 Created
Error:
{
"timestamp" : "2018-05-24T12:44:26.295+0000",
"status" : 500,
"error" : "Internal Error",
"message" : "USER_NOT_EXIST",
"success" : "false",
"path" : "/api/user/{userId}/userGroup"
}
Delete
# Http requestDELETE
http://localhost:8080/api/user/{userId}
HTTP/1.1
Request
Authorization : Bearer {jwt.token}
Content-Type : application/json
Response
Success:
204 No Content
Error:
{
"timestamp" : "2018-05-24T12:44:26.295+0000",
"status" : 500,
"error" : "Access Denied",
"message" : "ACCESS_DENIED",
"success" : "false",
"path" : "/api/user/{userId}"
}