Getting unauthorized exception in SAP ABAP


To fix this issue, you need to add try/catch response to the code. When you don’t include an authorization header, it results in an error 401 from the server.

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

Updated on: 18-Feb-2020

112 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements