You need to sign in to do that
Don't have an account?
Sahil Yadav
Passing the Data through POST Method Salesforce to External Application
Hello Developers,
I needed to pass an opportunitylineitem from salesforce to external application through Rest Api where in terms of http request the daya willl be passed from salesforce to other end .
But facing System.limit Exception while send the records and suggestion or improvisation needed in the code let me know.
For a Time being End Point Url i keep dummy and created a remote site setting as well
I needed to pass an opportunitylineitem from salesforce to external application through Rest Api where in terms of http request the daya willl be passed from salesforce to other end .
But facing System.limit Exception while send the records and suggestion or improvisation needed in the code let me know.
Global class IntegrationClass { /* @HttpGet global static List<opportunity> doGet() { RestRequest req = RestContext.request; RestResponse res = RestContext.response; String BuyerId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1); Account result = [SELECT Id, Name, Phone,Bi_Id__c, Website FROM Account WHERE Bi_Id__c = :BuyerId]; String acc = result.Id; List<Opportunity> opp = [Select id, name, accountId from Opportunity where accountId =:acc ]; return opp; }*/ public static void sendData(){ Http http = new Http(); HttpRequest request = new HttpRequest(); request.setEndpoint('https://www.google.com'); request.setMethod('POST'); List<OpportunityLineItem> opp = [Select id, name,ListPrice,UnitPrice, Opportunity.Id,Opportunity.CloseDate, Opportunity.Account.BI_ID__c from OpportunityLineItem where OpportunityId = '' AND Opportunity.Account.BI_ID__c = 'buy-7765']; String name = opp[0].name; Decimal listPrice = opp[0].ListPrice; Decimal unitPrice = opp[0].UnitPrice; Date closeDate = opp[0].Opportunity.CloseDate; request.setBody('{"Name":"name", "ListPrice" : "listPrice", "UnitPrice" : "unitPrice" , "CloseDate" : "closeDate"}'); request.setHeader('Content-Type', 'Application/Json; charset = UTF-8'); System.debug('!!!'+request); HttpResponse response = http.send(request); System.debug('!!!'+response); } } ==================================================================== Calling Integration Class Method:- IntegrationClass.sendData();
For a Time being End Point Url i keep dummy and created a remote site setting as well