Sample code for 30+ languages & platforms
Java

Shopware Digest Authentication

See more Shopware Examples

Demonstrates using Digest access authentication for Shopware.

Chilkat Java Downloads

Java
import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    boolean success = false;

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    CkHttp http = new CkHttp();

    // To use HTTP Digest Authentication, set the login and password, and also indicate that DigestAuth should be used.
    http.put_Login("api_username");
    http.put_Password("api_key");
    http.put_DigestAuth(true);

    CkStringBuilder sbResponseBody = new CkStringBuilder();
    success = http.QuickGetSb("https://my-shopware-shop.com/api/articles?limit=2",sbResponseBody);
    if (success == false) {
        System.out.println(http.lastErrorText());
        return;
        }

    CkJsonObject jResp = new CkJsonObject();
    jResp.LoadSb(sbResponseBody);
    jResp.put_EmitCompact(false);

    System.out.println("Response Body:");
    System.out.println(jResp.emit());
  }
}