在 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);
}

更新於: 18-2 月 -2020

165 個瀏覽量

開啟你的職業生涯

透過完成課程獲得認證

開始
廣告
© . All rights reserved.