In an apex funtion - getAttachments() - i'm requesting some attachments and their body:
Set<Id> attIds = new Set<Id>{id1, id2};
List<Attachment> attLst = [Select Name, Body From Attachment Where id in :attIds];
When calling this function from standard apex context i'm receiving the correct data. When calling this function from a rest context (let said that the rest WS calls a global doPost() function, and this function calls our getAttachments() function, I'm receiving the correct attachments name, but the body of the second attachment is the same body as the one of the first attachment.
code:
class A{
public static List<Attachments> getAttachments(Set<Id> ids){
List<Attachments> attLst = [Select Name, Body From Attachment Where id in :ids];
}
}
@RestResource(urlMapping='/merge2')
global class WS1{
@HttpPost
global static doPost(List<Id> idLst){
Set<Id> ids = new Set<Id>(idLst);
List<Attachment> attLst = A.getAttchments(ids);
}
}
When calling A.getAttachments I'm receiving the espected Attachments. When calling A.getAttachments from The WS, all the attachment's body are the same.
Any Idea? Thanks,
Ilan