Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I'm inserting the lead values from input form once it creates lead it makes a rest here i'm passing the
- lead values in "ENDPOINT URL" dynamically but instead of receiving the vales it displays the names
- please anybody help me on this
- I'm getting the response like this in debug logs
- System.HttpRequest[Endpoint=https://meet95927113.adobeconnect.com/api/xml?account-id=1300650024&session=apac1breezdaeh3dn9nnrbtdz3&action=event-register&sco-id=1307283681&login=Email1&password=1234&password-verify=1234&first-name=LastName1&last-name=LastName1, Method=POST]
- here login =Email1 and first-name=LastName1&last-name=LastName1 in these values i'm getting names insted of values
- this is my apex class:
- ----------------------
- global class AdobeToLead{
- public String Name;
- public String Email;
- global static void adobeToLeads(List<Lead> leads){
- Set<String> accNames = new Set<String>();
- List<Lead> leadadd = new List<Lead>();
- Map<String, Account> nameToAccount = new Map<String,Account>();
- List<Webinar_Attendee__c> wadd = new List<Webinar_Attendee__c>();
- for (Lead l : leads){
- accNames.add(l.Company);
- String LastName = l.LastName;
- String Email = l.email;
- for (Account record : [SELECT Name FROM Account WHERE Name IN :accNames ]){
- nameToAccount.put(record.Name, record);
- }
- if(nameToAccount.size()>0){
- List<Contact> clist = [Select ID,FirstName,LastName From Contact Where Account.Name=:l.Company AND LastName=:l.LastName];
- if(clist.size()>0){
- System.debug('clist ::: '+clist);
- for(Contact c1 : clist){
- LightiningEd__Webinar__c lw = [select id,OwnerId,Name from LightiningEd__Webinar__c limit 1];
- Webinar_Attendee__c wa = new Webinar_Attendee__c();
- wa.Name = l.FirstName;
- wa.Contact__c = c1.id;
- wa.LightiningEd__Webinar__c = lw.id;
- System.debug('Webinar value:::'+ wa.LightiningEd__Webinar__c);
- insert wa;
- l.addError('Duplicate Found');
- String Username = 'skbasha467@gmail.com';
- String Password = 'test12345';
- String endpointUrl = 'https://meet95927113.adobeconnect.com';
- LeadExportToAdobe.postLeadFuture(Username,Password,endpointUrl,LastName,Email);
- }
- }
- }
- else{
- Lead ll = new Lead();
- ll.LastName = l.LastName;
- ll.Company = l.Company;
- ll.Status = l.Status;
- ll.email = l.email;
- leadadd.add(ll);
- LightiningEd__Webinar__c lw = [select id,OwnerId,Name from LightiningEd__Webinar__c limit 1];
- String nameValue = lw.Name;
- Webinar_Attendee__c wae = new Webinar_Attendee__c();
- wae.Name = l.FirstName;
- wae.LightiningEd__First_Name__c = l.FirstName;
- wae.LightiningEd__Last_Name__c = l.LastName;
- wae.LightiningEd__Account_Name__c = l.LightiningEd__Account_Name__c;
- wae.LightiningEd__Webinar__c = lw.id;
- System.debug('Webinar attendeeWebinar Id :::'+wae.LightiningEd__Webinar__c);
- wadd.add(wae);
- String Username = 'skbasha467@gmail.com';
- String Password = 'test12345';
- String endpointUrl = 'https://meet95927113.adobeconnect.com';
- String lastName1 = l.LastName;
- String Email1 = l.email;
- LeadExportToAdobe.postLeadFuture(Username,Password,endpointUrl,Email1,lastName1);
- }
- }
- if(!leadadd.isEmpty()){
- insert leadadd;
- }
- if(!wadd.isEmpty()){
- insert wadd;
- }
- }
- }
- This my rest api
- -----------------
- global class LeadExportToAdobe{
- @future(callout=true)
- global static void postLeadFuture(String username, String password, String endpointUrl,String Email1,String LastName1) {
- exportLead(username, password, endpointUrl,Email1,LastName1);
- }
- global static HttpResponse exportLead(String Username, String Password, String endpointUrl,String Email1,String LastName1){
- //HttpResponse
- Http http = new Http();
- HttpRequest req = new HttpRequest();
- HttpResponse res = new HttpResponse();
- Blob headerValue = Blob.valueOf(username + ':' + password);
- String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
- req.setHeader('Authorization', authorizationHeader);
- req.setHeader('Content-Type', 'application/json');
- req.setEndpoint(endpointUrl+'/api/xml?account-id=1300650024&session=apac1breezdaeh3dn9nnrbtdz3&action=event-register&sco-id=1307283681&login=Email1&password=1234&password-verify=1234&first-name=LastName1&last-name=LastName1');
- req.setMethod('POST');
- try{
- res = http.send(req);
- System.debug('MyResult == :'+res.getBody());
- } catch(System.CalloutException e){
- System.debug('Callout error: '+ e);
- } return res;
- }
- }
- Thanks in advance,
- Baji
Add Comment
Please, Sign In to add comment