You need to sign in to do that
Don't have an account?
Rahul Kumar Dey
How to convert synchronous apex rest api web-service to Queueable interface (Asynchronous)?
Hi guys,
I want to convert and REST API web-service synchronous to queable-
Here is the code which is perfectly worked for upload attachment upto 5.5 MB 64 encoded file. And I see in the document we can upload upto 12MB if this is in asynchronous in nature.
Any help to convert this into queueable interface?
Thanks in advance
I want to convert and REST API web-service synchronous to queable-
Here is the code which is perfectly worked for upload attachment upto 5.5 MB 64 encoded file. And I see in the document we can upload upto 12MB if this is in asynchronous in nature.
@RestResource(urlMapping='/insertCaseWithAttachmentRestService/*') global with sharing class insertCaseWithAttachmentRestAPI { //In this method we insert case with multiple attached files @httpPost global static Id insertCase(caseRequest req){ Case caseObj = new Case(); caseObj.Product__c = req.pdt; caseObj.Type = req.type; caseObj.Status = req.status; caseObj.Origin = req.origin; caseObj.Subject = req.subject; insert caseObj; system.debug('CaseId->>>>'+caseObj.Id); List<Attachment> attList = new List<Attachment>(); for(attachmentRequest att : req.attList){ attList.add(new Attachment(Name=att.attachmentName, Body=EncodingUtil.base64Decode(att.blobString), ParentId=caseObj.Id )); } insert attList; return caseObj.Id; } //Wrapper class global class caseRequest{ String pdt {get; set;} String type {get; set;} String status {get; set;} String origin {get; set;} String subject {get; set;} List<attachmentRequest> attList {get; set;} } global class attachmentRequest{ String attachmentName {get; set;} String blobString {get; set;} } }
Any help to convert this into queueable interface?
Thanks in advance
Greetings!
In order to make the upload process as an asynchronous then you will have to implements the Queueable which enables you to add jobs to the queue and monitor them.
Please find the sample code along with the sample test class code:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_queueing_jobs.htm
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Warm Regards,
Shirisha Pathuri
Does your implementation require response with the newly created case ID to remote system?
If it doesn't, I'd split the functionality into two different classes and do something like this:
Do you have any alternate solution?
¿Did you find any solution about this issue?
I would appreciate if you answer me.
Greetings.
We couldn't achieve that using any of the apex solutions including synchronous & asynchronous because of the maximum payload is 6 MB/ 6000000 alphanumeric characters (including record size and attachments).
So our solution approach was, we no more store any attachments in Salesforce instead we stored those to AWS, and in the payload we requesting for the URL of AWS to create records with attachments into Salesforce.
Hope this helps!
Thanks,
Rahul