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
golugolu 

curl url callout

How do i make a post callout for this specific url ?

http://www.test.com/ComposeSMS.aspx?username=username&password=password&sender=senderid&to=MobileNo&message=Message

I am not able to figure out how to create the header and body for this specific url. I need to passs username , password , senderid , mobile number and message as parameters.

Any code snippet will be highly appreciated
Best Answer chosen by golu
Sharat C 2Sharat C 2
Hi,

Use this code, I haven't tested it though 
public class composeSMS{
	
	@future(callout = true)
	public static void compose(string username, string password, string senderId, string mobile,string message){
		
		HttpRequest req = new HttpRequest();
		String endpoint = 'http://www.test.com/ComposeSMS.aspx?';
		endpoint += 'username='+ username + '&password=' + password + '&sender='+ senderId + '&to='+ mobile + '&message='+message ;
		req.setEndpoint(endpoint);
        req.setMethod('POST');
        req.setHeader('Content-Type','text/xml');
        
		Http http = new Http();
		HttpResponse res = http.send(req);
		
		System.debug('STATUS:'+res.getStatus());
        System.debug('STATUS_CODE:'+res.getStatusCode());
	}
}

Thanks
Sharat