I am using an API for my desktop application. The application runs on dot.net framework 3.5.
I have an API which runs perfectly, but when i call the API from the desktop application, there is an error:
"The remote server returned an error: (404)"
But my API runs with no problem. I have two parameters, which will passed in the URL.
Here is my Code :
string url = "http://localhost:58167/api/Project/";
string data = "65354/19216882";
string response;
WebClient client = new WebClient();
{
client.Encoding = Encoding.UTF8;
response = client.downloadstring(url, "POST", data);
}
How can I solve the problem?
EDIT: Here is the code that illustrates how the API looks like:
// GET api/Project
public string GetProjects(string key, string IP)
{
string sql = "";
string en = "";
if (IP == "19216")
sql = "garbage1";
if (IP == "19882")
sql = " garbage2";
if (IP == "181249")
sql = " garbage3";
if (IP == "85206")
sql = " garbage4";
if (IP == "87249")
sql = " garbage5";
en = CryptorEngine.Encrypt(sql, key);
return en;
}
thank you all guys. i got my solved and i updated my update code in question. just change uploadstring to downloadstring . and bingo.. it works. –
update solved code:
string url = "http://localhost:58167/api/Project/";
string data = "65354/19216882";
string response;
WebClient client = new WebClient();
{
client.Encoding = Encoding.UTF8;
response = client.downloadstring(url, "POST", data);
}