getUserProfilePicture method Null safety
- int id
Get a user's profile picture.
id
must be the id of the user to get the picture.
Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#get-a-users-profile-picture
Implementation
Future<String> getUserProfilePicture(int id) async {
if (_sessionToken!.isEmpty) {
throw Exception('No session token, initSession first');
}
final Map<String, String> headers = {
'Session-Token': _sessionToken!,
'Content-Type': 'application/json',
...?appToken != null ? {'App-Token': appToken!} : null,
};
final uri = Uri.parse('$baseUrl/User/$id/Picture');
final response = await http.get(uri, headers: headers);
if (response.statusCode != 200 && response.statusCode != 207) {
throw GlpiException.fromResponse(
response.statusCode, json.decode(response.body));
}
return Future.value(response.body);
}