+ Start a Discussion
Nagesh B 13Nagesh B 13 

wanna update Profile Image by using CHATTER API after getting the Image from external Source using HTTP Response.


i have one requirement where should i call HttpRequest for Image and after getting the response i should take that image and set as that image as Current User profile image.  mine is not communirty. 

i have written below logic, but when i am checking documnet record attachment i am seeing blank image but having size.
please help me on this if i am doing anything wrong. 

           Http h = new Http();
           HttpRequest req = new HttpRequest();
           req.setHeader('Content-Type', 'image/jpg');
           HttpResponse res = h.send(req);
           Blob body = res.getBodyAsBlob();
            Document document = new Document();
            document.AuthorId = UserInfo.getUserId();
            document.FolderId = UserInfo.getUserId(); 
           document.Body = body;
            document.IsPublic = true;
            insert document;
          ConnectApi.BinaryInput photoFileInput = new ConnectApi.BinaryInput(body,'image/jpg',iosx.Name__c);  
          ConnectApi.photo profilepic=ConnectApi.UserProfiles.setPhoto(null,UserIdValue,photoFileInput);