Guest User

Untitled

a guest
Jan 4th, 2018
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.85 KB | None | 0 0
  1. I'm inserting the lead values from input form once it creates lead it makes a rest here i'm passing the
  2. lead values in "ENDPOINT URL" dynamically but instead of receiving the vales it displays the names
  3. please anybody help me on this
  4.  
  5. I'm getting the response like this in debug logs
  6.  
  7. 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]
  8.  
  9. here login =Email1 and first-name=LastName1&last-name=LastName1 in these values i'm getting names insted of values
  10.  
  11. this is my apex class:
  12. ----------------------
  13.  
  14. global class AdobeToLead{
  15.  
  16. public String Name;
  17. public String Email;
  18. global static void adobeToLeads(List<Lead> leads){
  19. Set<String> accNames = new Set<String>();
  20. List<Lead> leadadd = new List<Lead>();
  21. Map<String, Account> nameToAccount = new Map<String,Account>();
  22. List<Webinar_Attendee__c> wadd = new List<Webinar_Attendee__c>();
  23. for (Lead l : leads){
  24. accNames.add(l.Company);
  25. String LastName = l.LastName;
  26. String Email = l.email;
  27.  
  28. for (Account record : [SELECT Name FROM Account WHERE Name IN :accNames ]){
  29. nameToAccount.put(record.Name, record);
  30. }
  31. if(nameToAccount.size()>0){
  32.  
  33. List<Contact> clist = [Select ID,FirstName,LastName From Contact Where Account.Name=:l.Company AND LastName=:l.LastName];
  34. if(clist.size()>0){
  35. System.debug('clist ::: '+clist);
  36. for(Contact c1 : clist){
  37. LightiningEd__Webinar__c lw = [select id,OwnerId,Name from LightiningEd__Webinar__c limit 1];
  38. Webinar_Attendee__c wa = new Webinar_Attendee__c();
  39. wa.Name = l.FirstName;
  40. wa.Contact__c = c1.id;
  41. wa.LightiningEd__Webinar__c = lw.id;
  42. System.debug('Webinar value:::'+ wa.LightiningEd__Webinar__c);
  43. insert wa;
  44. l.addError('Duplicate Found');
  45. String Username = 'skbasha467@gmail.com';
  46. String Password = 'test12345';
  47. String endpointUrl = 'https://meet95927113.adobeconnect.com';
  48.  
  49. LeadExportToAdobe.postLeadFuture(Username,Password,endpointUrl,LastName,Email);
  50.  
  51. }
  52. }
  53. }
  54. else{
  55. Lead ll = new Lead();
  56. ll.LastName = l.LastName;
  57. ll.Company = l.Company;
  58. ll.Status = l.Status;
  59. ll.email = l.email;
  60. leadadd.add(ll);
  61. LightiningEd__Webinar__c lw = [select id,OwnerId,Name from LightiningEd__Webinar__c limit 1];
  62. String nameValue = lw.Name;
  63. Webinar_Attendee__c wae = new Webinar_Attendee__c();
  64. wae.Name = l.FirstName;
  65. wae.LightiningEd__First_Name__c = l.FirstName;
  66. wae.LightiningEd__Last_Name__c = l.LastName;
  67. wae.LightiningEd__Account_Name__c = l.LightiningEd__Account_Name__c;
  68.  
  69.  
  70. wae.LightiningEd__Webinar__c = lw.id;
  71. System.debug('Webinar attendeeWebinar Id :::'+wae.LightiningEd__Webinar__c);
  72. wadd.add(wae);
  73.  
  74. String Username = 'skbasha467@gmail.com';
  75. String Password = 'test12345';
  76. String endpointUrl = 'https://meet95927113.adobeconnect.com';
  77. String lastName1 = l.LastName;
  78. String Email1 = l.email;
  79. LeadExportToAdobe.postLeadFuture(Username,Password,endpointUrl,Email1,lastName1);
  80.  
  81. }
  82. }
  83. if(!leadadd.isEmpty()){
  84. insert leadadd;
  85. }
  86. if(!wadd.isEmpty()){
  87. insert wadd;
  88.  
  89. }
  90. }
  91. }
  92.  
  93. This my rest api
  94. -----------------
  95.  
  96. global class LeadExportToAdobe{
  97.  
  98. @future(callout=true)
  99. global static void postLeadFuture(String username, String password, String endpointUrl,String Email1,String LastName1) {
  100.  
  101. exportLead(username, password, endpointUrl,Email1,LastName1);
  102.  
  103. }
  104.  
  105. global static HttpResponse exportLead(String Username, String Password, String endpointUrl,String Email1,String LastName1){
  106. //HttpResponse
  107. Http http = new Http();
  108. HttpRequest req = new HttpRequest();
  109. HttpResponse res = new HttpResponse();
  110. Blob headerValue = Blob.valueOf(username + ':' + password);
  111. String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
  112. req.setHeader('Authorization', authorizationHeader);
  113. req.setHeader('Content-Type', 'application/json');
  114. 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');
  115. req.setMethod('POST');
  116. try{
  117. res = http.send(req);
  118. System.debug('MyResult == :'+res.getBody());
  119.  
  120. } catch(System.CalloutException e){
  121.  
  122. System.debug('Callout error: '+ e);
  123. } return res;
  124. }
  125. }
  126.  
  127.  
  128. Thanks in advance,
  129. Baji
Add Comment
Please, Sign In to add comment