How to capture Profile Picture from Azure Entra ID into ServiceNow User record?

Sharmila2
Tera Contributor

Hi All,

 

I am trying to capture Profile Picture for users with the data coming from Azure Entra ID. I created a IntegrationHub action to call Azure Entra ID endpoint for the profile picture and the data received is "binary data of a PNG file". Now I am trying to convert this binary data into Base64 encoded format to use that information and store it as an attachment. I am following this KB article https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0597756 and trying to replicate the same logic. Below is the logic in Action step.

 

 

var attachment = new GlideSysAttachment();
var EncodedBytes = GlideStringUtil.base64Encode(inputs.binary_data);

//set up inputs
var rec = new GlideRecord('sys_user');
rec.get('sys_id_of_user_record');
var fileName = 'image.png';
var contentType = 'image/png';
var content = GlideStringUtil.base64DecodeAsBytes(EncodedBytes);
var agr = attachment.write(rec, fileName, contentType, EncodedBytes);

 

 

File is getting attached to the user record, but the file which is generated is not in a recognized format. Can anyone share their experience in capturing Profile picture information from any sources into ServiceNow?

0 REPLIES 0