cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

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

maharzn116
Explorer
0 Likes
1,777

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.

Accepted Solutions (0)

Answers (1)

Answers (1)

shivjipatel
Explorer
0 Likes

You need to set the ExpectContinue on the headers to false if you are using .NET Framework. This header does not get sent when using the .Net Core version of HttpClient.

client.DefaultRequestHeaders.ExpectContinue = false;