StringUtil.base64Encode(response.getBody()); returning improper code

Rohit Kumar
Giga Expert

I am facing a situation where below function is not returning the appropriate format in base64. Base64 format starts with /9 however, we are getting (binData) it in the format of

77+977+977+977+9ABBKRklGAAEBAQB4AHgAAO+/ve+/v.................

var binData = StringUtil.base64Encode(response.getBody());

Please suggest.

pradeepksharma johnandersen

Thanks

Rohit

1 ACCEPTED SOLUTION

Thanks Ujjawal, It returned the same. ServiceNow said it doesn;t support images etc in REST API.


However, please refer to the below link as my issue was resolved via different method.



Inserting Attachments in ServiceNow from JIRA without MID-Server using REST


View solution in original post

2 REPLIES 2

Ujjawal Vishnoi
Mega Sage
Mega Sage

Hi Rohit,



How are you validating that it is not returning the correct value.



For validating you can use below mentioned code to encode and decode it back in background script.



var base64string = GlideStringUtil.base64Encode("Your response");


var abc=GlideStringUtil.base64Decode(base64string);


gs.print(abc);



If you still see the difference or any issue then please do let me know.



Hope this helps.



Regards


Ujjawal


Thanks Ujjawal, It returned the same. ServiceNow said it doesn;t support images etc in REST API.


However, please refer to the below link as my issue was resolved via different method.



Inserting Attachments in ServiceNow from JIRA without MID-Server using REST