Click here to Skip to main content
16,020,261 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Source code:

request.AddHeader("Content-Type", "application/json");
                request.AddHeader(_appSettings.SAPConfig.CSRFTokenName, _appSettings.SAPConfig.CSRFTokenValue);
                request.AddHeader("Cookie", _appSettings.SAPConfig.CookieValue);
                request.AddHeader("Username", "xyz" );
                request.AddHeader("Password", "xyz");
                request.AddHeader("Authorization", $"XYZ");
                ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
                client.AddDefaultHeader("User-Agent", "UserAgent");
                IRestResponse response = await client.ExecuteAsync(request);


What I have tried:

When I execute this below code in VS2019 enterprise version. I am getting the Forbidden error.
But the same code executed and got response when open this application in VS2019 Professiona version. can you please tell me what is the problem here
Posted
Updated 15-May-22 23:43pm
Comments
Rajeev Jayaram 16-May-22 7:04am    
What is the error you are getting?

1 solution

We can't help - we have no way to run the code under the same circumstances you do, and that is essential in order to begin working out where the problem is. We don't even have access to the full error information!

So, it's going to be up to you.
Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. If you don't know how to use it then a quick Google for "Visual Studio debugger" should give you the info you need.

Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900