on 10-07-2021 1:58 AM
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.
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;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
104 | |
12 | |
11 | |
6 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.