Skip to Content
0
Oct 07 at 12:58 AM

How to use SAP B1 service layer in addon project for sap 10 with .net framework 4.5.1 ?

51 Views Last edit Oct 13 at 05:15 PM 3 rev

I am unable to connect SAP Business One Service Layer using .NET Framework. It throws the error Internal Server Error with status code 500.

HttpClient client = new HttpClient();

string json = JsonConvert.SerializeObject( new {

CompanyDB = "company",

UserName = "username",

Password = "password" } );

var response = await client.PostAsync("service layer URL", new StringContent(json, Encoding.Default, "application/json"));

Although I am able to connect to the service layer using the .NET Core application with the same code.

I have gone through this blog https://blogs.sap.com/2015/07/15/how-to-consume-service-layer-odata-services-from-net-via-wcf/

But I am unable to Add Service Reference for the service layer. I am not sure whether this problem belongs to the service layer or my program. Do we need to do extra code to call the OData service (as the service layer is oData V3 or V4) from the .net framework? Please help me to solve this problem.