cancel
Showing results for 
Search instead for 
Did you mean: 

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

maharzn116
Explorer
0 Kudos

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.

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Dear maharzn116,

What is meant by unable to Add Service Reference for the service layer?

Are you getting any error? Kindly share a screenshot for the same.

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

n007praveen71
Participant
0 Kudos

Hi maharzn116,

Try changing your .NET Framework to 4.0

Accepted Solutions (0)

Answers (1)

Answers (1)

shivjipatel
Discoverer
0 Kudos

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;