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