function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ray k.ax948ray k.ax948 

HTTP POST VARIABLES IN SF

Hi all,

 

I want to make a web service call for which i have the end point URL and xml that need to be passed. I need to pass a POST variable. Can anyone please help me on how to pass a POST variable through HTTP Request.?

 

Thanx in Advance

Ray

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Bhawani SharmaBhawani Sharma

or you can try with :

 

req.setBody('param1='+param1 +'&param2='+param2);

All Answers

kzmpkzmp

Which language are you using?

If you are using Asp.net or ASP.MVC please look at Paypal's API they have an example of sending post variables to their service which you can translate.

Actually they should have the same for the other languages as well.

 

Regards,

Kzmp

ray k.ax948ray k.ax948

Hi,

 

I am using salesforce HttpRequest class to make the web service call but cannt find a way to attach a variable in my Httprequest.

basically i have my end point and xml which i need to specify in the body.Along with the xml i need to specify a variable also for which i cannt find a method in salesforce HTTPREquest class.

I just want to know that how i can attach a variable with HTTP POST request.

 

Thanks,

Ray

Bhawani SharmaBhawani Sharma
request.setHeader('ParameterName', parameterValue);
Bhawani SharmaBhawani Sharma

or you can try with :

 

req.setBody('param1='+param1 +'&param2='+param2);
This was selected as the best answer
ray k.ax948ray k.ax948

hi all,

 

actually i solved the problem as it was a post we have to specify the variabls in body of the request only as given by bhawani..thanx for that. and also i was specifying my header as request.setHeader('content-type','text/html') which i do not need.

 

thnx all for the help.

Regards,

Ray