Using HTTPClient to Integrate Backend Systems

Use the HTTPClient class to create an HTTP client.

The HTTPClient class supports the following HTTP methods:

  • GET
  • POST
  • HEAD
  • PUT
  • DELETE
Important:

For security reasons, we recommend that you always use HTTPS when connecting to external servers. A Certificate Authority (CA) that B2C Commerce recognizes must sign the certificate at the external server. You can import more CAs in Business Manager.

 var httpClient : HTTPClient = new HTTPClient();
 httpClient.setTimeout(2000);
 var message : String;
 httpClient.open('GET', 'http://www.myinstance.com/feed.xml');
 httpClient.send();

 if (httpClient.statusCode == 200)
 {
      message = httpClient.text;
 }
 else
 {
     // error handling
     message="An error occured with status code "+httpClient.statusCode;
 }