I am trying to consume a third party service like this:
var context = new DataSource(new Uri("http://api.olr.com/Service.svc"));
context.Credentials = new NetworkCredential("username", "password", "http://api.olr.com/Service.svc");
var agents = from a in context.Agents
select a;
tbResponse.Text = agents.FirstOrDefault().ToString();
but getting reponse:
<div class="content-container"><fieldset>
<h2>401 - Unauthorized: Access is denied due to invalid credentials.</h2>
<h3>You do not have permission to view this directory or page using the credentials that you supplied.</h3>
</fieldset></div>
</div>
I tried to access the service using browser and it is working.
third parameter to following line is domain. what to put in domain ? the Service url as i did ?
context.Credentials = new NetworkCredential("username", "password", "http://api.olr.com/Service.svc");
The NetworkCredential constructor is expecting username, password and domain but you are passing in the full Url instead of the domain.
I would change that line to:
UPDATE – Solution that worked:
Was the solution.