I have a service that allows me to change a user's profile picture.
The petition type is POST, and it has the following structure:
{
"UserId":"0057E000008wDTRQA2",
"PhotoUrl":"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD[...]" //shortened
}
What I'm trying to do is update my users profile picture with this (entry is the object storing request properties):
document = new Document();
document.Type = 'jpg';
document.IsPublic = true;
document.AuthorId = entry.UserId;
document.FolderId = entry.UserId;
document.Name = 'New Profile picture';
document.Body = EncodingUtil.base64Decode(entry.PhotoUrl);
insert document;
//Update user profile picture
ConnectApi.Photo photo = ConnectApi.UserProfiles.setPhoto(null, entry.UserId, new ConnectApi.BinaryInput(document.Body, 'image/jpg', 'newprofile.jpg'));
And it's giving me the following error:
Unrecognized base64 character: :
Does anyone know how can I solve this?
Regards