We are moving from Nav 2009 to 2015. In 2009 I have a call to a web service where I use the 'Microsoft XML, v3.0'.XMLHTTP' automation, and send username and password like this 'XmlHttp.open('POST',txtURL, FALSE, UserID,Password);'
in 2015 I want to use 'System.Net.HttpWebRequest' Dotnet.
I cant figure out how to pass credentials to the webrequest, it seems like I should be creating an instance of the 'System.Net.CredentialCache' but i cant access this class from Dynamics Nav.
Any ideas ?
BR
Peter
0
Comments
Microsoft - Dynamics NAV
Thank you for the answer.
I've allready been looking ind CU 1290, but I cant find an example on how to specify username and password.
Instead i've tried to use a header value like this, but this gives me an error 401
HttpRequestHeader := HttpWebRequest.Headers();
HttpRequestHeader.Add('Authorization','Basic Username:Password');
I found the class System.Net.NetworkCredential
And then I could handle it like this
Credentials := Credentials.NetworkCredential(UserName,Password);
HttpWebRequest.Credentials := Credentials;
It works fine
BR
Peter