Set User Image
Set the profile image for a user.
POST https://instance.securid.com/aveksa/command.submit?cmd=setUserImage
note
Requires User:Edit privilege for the specified user. The image must be sent Base64 encoded in the request body with Content-Type: image/png.
Request
Parameters
| setUserImage | |
| format | properties - (Default) Returns the response as key=value pairs.json - Returns the response as JSON. |
| userId | The user ID of the user to set the image for. If omitted, the image is applied to the user associated with the token. |
Headers
Bearer token | |
| Accept | application/json |
| image/png |
Body
Base64 encoded PNG image data.
Response
This command returns no output parameters. Use the HTTP status code to determine success.
Examples
Request
- Curl
- Python
- Node.js
curl -K -X POST \
"https://instance.securid.com/aveksa/command.submit?cmd=setUserImage&userId=1" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: image/png" \
-d "<base64-encoded PNG data>"
import requests
import base64
url = "https://instance.securid.com/aveksa/command.submit"
params = {
"cmd": "setUserImage",
"userId": "1"
}
headers = {
'Authorization': 'Bearer <token>',
'Content-Type': 'image/png'
}
with open("user.png", "rb") as f:
payload = base64.b64encode(f.read()).decode('utf-8')
response = requests.post(url, params=params, headers=headers, data=payload)
if response.status_code == 200:
data = response.json()
print(data)
else:
print(f"Request failed with status code {response.status_code}")
const axios = require('axios');
const fs = require('fs');
const url = "https://instance.securid.com/aveksa/command.submit";
const params = {
cmd: "setUserImage",
userId: "1"
};
const headers = {
'Authorization': 'Bearer <token>',
'Content-Type': 'image/png'
};
const payload = fs.readFileSync('user.png').toString('base64');
axios.post(url, payload, { params, headers })
.then(response => {
if (response.status === 200) {
console.log(response.data);
} else {
console.log(`Request failed with status code ${response.status}`);
}
})
.catch(error => {
console.error('Error:', error);
});
Response
- 200
- 401 Invalid Token
- 400 Wrong Content-Type
- 500 Invalid Image Data
{
"data": {
"type": "setUserImage"
}
}
<html>
<head>
<title>Error</title>
</head>
<body>The token is not valid for the command 'setUserImage'. Token is invalid or expired</body>
</html>
Returned when the request is sent without Content-Type: image/png.
Returned when the request is sent with an incorrect Content-Type.
<html>
<head>
<title>Error</title>
</head>
<body>The content-type must be multipart/form-data with the content set to content-type image/png
Query String=cmd=setUserImage&userId=1</body>
</html>
Returned when the body cannot be decoded as a valid Base64-encoded PNG.
<html>
<head>
<title>Error</title>
</head>
<body>java.lang.Exception: The File upload for sample-user failed: Illegal base64 character -1</body>
</html>
Verified with RSA Governance & Lifecycle version 8.0.0.188886 P10_HF01.