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

Unable to get Authorized object

sarmad72
Discoverer
0 Kudos
218

Hi, 
I am using SAP B1.Can someone please help me with this, When I am trying to getting the session id from the Postman its giving me success response 

sarmad72_0-1762424828304.png

But when I am trying to do same thing with .net code its throwing the error 

sarmad72_1-1762424921084.png


Here is my code snippet as well

string endpoint = $"{baseURL.TrimEnd('/')}/{version.Trim('/')}/Login";

var payload = new
{
CompanyDB = "SBODemoUS",
UserName = "manager",
Password = "xxxxxxx"
};

string jsonContent = JsonConvert.SerializeObject(payload);
var handler = new HttpClientHandler
{
ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true
};

var httpclient = new HttpClient(handler);
var content = new StringContent(jsonContent, null, "application/json");
var response = await httpclient.PostAsync(endpoint, content);
if (!response.IsSuccessStatusCode)
{
var responseContent = await response.Content.ReadAsStringAsync();
}


I also overserved that when I am trying to run the same code from .net core its working but when I am trying with .net 4.7 its throwing error. 

Accepted Solutions (0)

Answers (0)