我试图实现drawloop配置,通过该配置我可以使用webserive调用将pdf文件附加到case对象。下面是我的代码段。
我面临的问题是获取其他用户的会话ID。如果我以请求的用户身份登录并执行以下代码,它将可以正常工作。
如果我与其他用户登录并执行以下代码,则它将无法正常工作。不会将pdf附加到drawloop的大小写中。
如果有人遇到同样的问题,请。非常感谢您的帮助。
@Future(callout=true)
public static void invokeDDP(Id caseID) {
HTTP auth = new HTTP();
HTTPRequest req = new HTTPRequest();
req.setEndpoint('https://test.salesforce.com/services/oauth2/token');
req.setHeader('Authorization', 'OAuth');
req.setMethod('POST');
req.setBody('grant_type=password' +
'&client_id= xxxx' +
'&client_secret= xxxx' +
'&username= xxxx' +
'&password= xxxx');
HTTPResponse authresp=new HttpResponse();
authresp = auth.send(req);
system.debug('response ->'+authresp);
System.debug('BODY: '+authresp.getBody());
System.debug('STATUS:'+authresp.getStatus());
System.debug('STATUS_CODE:'+authresp.getStatusCode());
System.debug('\n response List -> '+authresp.getBody());
Map<string, object > results =( Map<string, object >)Json.deserializeuntyped(authresp.getBody());
String actoken = (string)results.get('access_token');
Loop__DDP__c ddps = [SELECT Id, (SELECT Id FROM Loop__Custom_Integration_Options__r WHERE Name = 'Attach' LIMIT 1) FROM Loop__DDP__c WHERE Name ='Attach' LIMIT 1];
Loop.loopMessage lm = new Loop.loopMessage();
lm.sessionId = actoken;
lm.batchNotification = Loop.loopMessage.Notification.ON_ERROR;
lm.requests.add(new Loop.loopMessage.loopMessageRequest(
caseID,
ddps.Id,
new Map < string, string > {
'deploy' => ddps.Loop__Custom_Integration_Options__r[0].Id
}
));
lm.sendAllRequests();
}