'How to add credentials to ODATA Microsoft dynamics web service, on Visual Studio 2019
The Microsoft dynamic web service link when used on a browser prompts the Credentials as shown in the image below

The issue is how to pass this credential to Visual studio in order to avoid the Unauthorized response
I have tried:
Authorisation:Basic
username: valid username
password: valid password
on the Custom Headers textbox, having ticked include custom http headers
Solution 1:[1]
As explained in this related post, you can supply the user credentials as follows:
var client = new RestClient(Url);
var request = new RestRequest(Method.GET);
client.FollowRedirects = true;
client.Timeout = -1;
client.PreAuthenticate = true;
request.Credentials = new NetworkCredential(User, Password);
You already replaced the domain name of the Dynamics system with its IP address. Make sure that the service is actually active. Are there any access restrictions in place which prevent the user from calling this service? Check the event log entries on the server side.
Test the connection/credentials with postman. Such a test can rule-out problems outside your code. If postman is able to perform a sucessful call, your code is the culprit.
Campany in the service URL is not spelled correctly?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

