Click here to Skip to main content
15,887,822 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Team,

I'm trying to connect webservice for SharePoint library attachments download purpose and I used the below piece of code.

But I got error like "Invalid URI: A port was expected because of there is a colon(':') present but the port could not be parsed."


C#
WebService.Lists objLists = new WebService.Lists();

objLists.Credentials = System.Net.CredentialCache.DefaultCredentials; //here i got empty user and domain so i thought that because of this error may occur so i changed this line with this 

System.Net.NetworkCredentials userdetails=new System.Net.NetworkCredentials(username,pwd,domain);


objLists.Credentials = userdetails;

objLists.Url = "http://[SITENAME]:2009/_vti_bin/lists.asmx";



If any one having idea about this request you to kindly help me to resolve this issue.

What I have tried:

As per my Google experience because of User credentials the error may arise, so i thought that if we pass proper user details then it may work and I hard coded user details and tried but no luck.


and I noticed onething in error details like port required because of there is a colon(':'), but I pass the correct port and my URL format is like below

http://sitename:port/_vti_bin/lists.asmx

and one more thing I can able to access the service by hitting URL in browser.
Posted

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