Skip to main content
So we need to POST over some JSON data upon a new appointment being created in our system and then GET data once a new quote is made. 

Here is my code - it is my first one so excuse the lack of quality here. I am open to any and all suggestions. I'm not sure exactly but I keep getting an error "Unexpected syntax: mismatched input 'content-type' expecting RPAREN", "Unexpected token: ." pretty much on all of the req.setHeader lines. 

Any insight you could provide would be GREATLY appreciated. Thank you so much!

 

public with sharing class HTTPPosting {

HttpRequest req = new HttpRequest();

//Set HTTPRequest Method

req.setMethod('POST');

//Set HTTPRequest header properties

req.setHeader('content-type', 'application/json');

req.setHeader('Content-Length','1024');

req.setHeader('Accept','application/json');

req.setTimeout(120000);

req.setEndpoint('https://platform.modsolar.net/rest/createLead/{myAPIkeygoeshere}/');

//Set the HTTPRequest body

req.setBody('externalLeadId=ApptID__c&FName2__c=i360__Prospect_Name__c&Street__c=i360__Address__c&City__c=i360__City__c&State__c=i360__Prospect_State__c&Postal_Zip__c=i360__Zip__c&phone=i360__Prospect_Phone__c');

Http http = new Http();

try {

//Execute web service call here

HTTPResponse res = http.send(req);

//Helpful debug messages

System.debug(res.toString());

System.debug('STATUS:'+res.getStatus());

System.debug('STATUS_CODE:'+res.getStatusCode());

} catch(System.CalloutException e) {

//Exception handling goes here....

}

}

 
1 respuesta
0/9000