Posted on 19/09/2023 10:21:29
							
							
						 
						A little context:
Our customer has some product information that we request from the frontend after initial page load. We do this because it can be quite a heavy task.
The customer's BC partner have made a new endpoint, so vi kan use the ICC app to get the information. That means I have set up an ICC app that returns json when fetched. 
If I fetch the app when not logged in, it just returns "No user logged in" it never tries to contact BC. Earlier I fixed this with your solution and added username and password for a dummy user.
My request is a simple javascript fetch: 
lookUpBundle: async function(productNo, url) {
    this.loadingBundles = true;
    let requestUrl = `@(BundleLookup)&ICC_itemId=${productNo}`;
    if(url && url != "") {
        requestUrl = url;
    }
    if(!this.isLoggedIn) {
        if(requestUrl.indexOf('username') < 0) {
            requestUrl += '&username=mailtest@gotcha.dk&password=K123456';
            this.tempLoggedIn = true;
        }
    }
    fetch(requestUrl, {
        credentials: "same-origin"
    })
    .then(response => response.json())
    .then(response => {
  ...
  }
}
The ICC app. uses this template:
@{
    int x = 0;
    bool hasPages = !String.IsNullOrWhiteSpace(GetString("Ecom:IntegrationCustomerCenter.Paging.HasPages")) ? true : false;
    string nextPage = "";
    if(hasPages && GetInteger("Ecom:IntegrationCustomerCenter.Paging.CurrentPage") < GetInteger("Ecom:IntegrationCustomerCenter.Paging.NumPages")) {
        nextPage = GetString("Ecom:IntegrationCustomerCenter.Paging.Forward.URL");
    }
}
{
    "bundleCount": @GetLoop("Ecom:IntegrationCustomerCenter.BundleLoop").Count(),
    "nextPage": "@nextPage",
    "currentPage": @GetInteger("Ecom:IntegrationCustomerCenter.Paging.CurrentPage"),
    "bundles": [
        @foreach(var bundle in GetLoop("Ecom:IntegrationCustomerCenter.BundleLoop")) {
            x++;
            if(x > 1) {
                <text>,</text>
            }
            <text>
                {
                    "bundleNo": "@bundle.GetString("BundleNo")",
                    "thickness": "@bundle.GetString("Thickness")",
                    "length": "@bundle.GetString("Length")",
                    "width": "@bundle.GetString("Width")",
                    "stock": {
                        "warehouse": "@bundle.GetString("Stock")",
                        "sea": "@bundle.GetString("StockSea")",
                        "units": "@bundle.GetString("StockUnits").Replace(",", "")",
                        "seaUnits": "@bundle.GetString("StockSEAUnits")"
                    }
                }
            </text>
        }
    ]
}
This used to work. And to my knowledge, the only thing that has changed is we updated the solution to 9.15.8.