You need to sign in to do that
Don't have an account?
Michael Hedrick 2
Calling web service is this the correct approach
Hello All,
I need to call a web service from Salesforce. So I have been informed that the end point url will need to look like this with parameter.
I knowall of the required fields are not in the string url but I was not sure if I approaching this correctly. I am trying to send data to the webservice and I am not returning anything. Any help is appreciated.
Cheers,
M
I need to call a web service from Salesforce. So I have been informed that the end point url will need to look like this with parameter.
GET /abc/def.asmx/ghi?emailTo=string&firstName=string&lastName=string&leadType=string&activityType=string&agree=string&source=string&status=string&streetAddress=string&streetAddress2=string&city=string&state=string&zip=string&country=string&sendsEmail=string&emailFrom=string&activitySubjectMy cass looks like this:
public class CallTrexWebServiceInsideSales { Lead leads; string message; { message = ''; leads = [SELECT Email, FirstName , LastName , RecordTypeId, city, FROM Lead WHERE Id = :ApexPages.currentPage().getParameters().get('id')]; if(String.isEmpty(leads.email) || String.isEmpty(leads.Account_Type__c)) { message = 'This lead is either missing an email address or the Account Type field is NULL.' ; } } public String myresponse{get;set;} public Pagereference getResult() { HttpRequest req = new HttpRequest(); Http http = new Http(); req.setMethod('GET'); String ActivityType = 'Sales'; string Subject = 'test; String url = 'https://abc/def.asmx/ghi?'+leads+ActivityType +Subject; req.setEndpoint(url); HTTPResponse resp = http.send(req); myresponse=resp.getBody(); return null; } }
I knowall of the required fields are not in the string url but I was not sure if I approaching this correctly. I am trying to send data to the webservice and I am not returning anything. Any help is appreciated.
Cheers,
M
Regards,
Amit
All Answers
Regards,
Amit
Cheers,
M
Do I have to use Webservice static void testMethod() to be able to call this class from a Detailed record button?
Thanks,
M
I am getting the following errro:
11:30:53:001 FATAL_ERROR System.NullPointerException: Attempt to de-reference a null object
11:30:53:000 FATAL_ERROR Class.CallTrexWebServiceInsideSales.TrexWebServiceInsideSales: line 9, column 1
11:30:53:001 FATAL_ERROR System.NullPointerException: Attempt to de-reference a null object
I can see that I am getting the Id of the Lead so I ma not sure what the error is referencing
Class:
Button:
Refer below link for more information
http://blog.shivanathd.com/2014/07/call-apex-class-from-custom-button-salesforce.html
Basically I need to follow the string values required by the web service:
Call TrexWebServiceInsideSales method from the javascript and pass the Lead Id
Now I will see if I cna put a Test class togther...
Thanks for your help and have a good weekend.
M