HTTPClient with Scripting

The HTTPClient class implements the HTTPClient for Salesforce B2C Commerce script, by supporting the HTTP methods: GET, POST, HEAD, PUT and DELETE.

Salesforce recommends that you use the web service implementation in the dw.svc package instead of using HTTPClient directly, because it adds analytics and timeout management.

Example

var request : HTTPClient = new HTTPClient();
   try {
    request.open("GET", requestString);
    request.send();
    var xmlObj : XML = new XML(request.getText());
    var xmlList : XMLList = xmlObj.children().children();
	var recommendations : LinkedHashSet = new LinkedHashSet();
    for each( var item in xmlList)
    {
    	var productID : String = item["product-id"];
	var product = dw.catalog.ProductMgr.getProduct(productID);
		if(product != null)
		{
	 		recommendations.add( product );
	   	}
Note: See the API documentation for more information.