在 SAP ABAP 中出现未经授权的异常


为修复该问题,您需要将 try/catch 响应添加到代码中。当您不包含授权标头时,会引发服务器的 401 错误。

try {
    CatalogService.CatalogChangeClient service =
     new CatalogService.CatalogChangeClient();
    service.ClientCredentials.UserName.UserName = "username";
    service.ClientCredentials.UserName.Password = "password";
    service.ClientCredentials.SupportInteractive = true;
    ProductUpdate[] products = new ProductUpdate[1];
    products[0] = new ProductUpdate();
    products[0].ProductCode = "00001";
    products[0].ProductDescription = "TestProduct";
    string result = service.UpdateProducts(products);
} catch (Exception exception) {
    Console.WriteLine(exception.Message);
}

更新于: 2020-02-18

165 次浏览

开启您的职业生涯

完成课程获得认证

开始
广告
© . All rights reserved.