Sample code for 30+ languages & platforms
JavaScript

Shopware Digest Authentication

See more Shopware Examples

Demonstrates using Digest access authentication for Shopware.
Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat v11.4.0 or greater.
JavaScript
var success = false;

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

var http = new CkHttp();

// To use HTTP Digest Authentication, set the login and password, and also indicate that DigestAuth should be used.
http.Login = "api_username";
http.Password = "api_key";
http.DigestAuth = true;

var sbResponseBody = new CkStringBuilder();
success = http.QuickGetSb("https://my-shopware-shop.com/api/articles?limit=2",sbResponseBody);
if (success == false) {
    console.log(http.LastErrorText);
    return;
}

var jResp = new CkJsonObject();
jResp.LoadSb(sbResponseBody);
jResp.EmitCompact = false;

console.log("Response Body:");
console.log(jResp.Emit());