I am trying to upload data to a REST-Service via POST-Method, but for some reasons the server tells me:
System.Net.WebException: The remote server returned an error: NotFound.
I am trying to upload data with this code:
WebClient addserving = new WebClient();
addserving.Credentials = new NetworkCredential(username.Text, passwort.Password);
addserving.Encoding = System.Text.Encoding.GetEncoding("ISO-8859-1");
addserving.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
addserving.UploadStringAsync(new Uri("http://jokr.info/api/v8/diary/add_item.xml&apikey=123456&item_id=1240&serving_id=1566"), "POST");
addserving.UploadStringCompleted += new UploadStringCompletedEventHandler(serving_UploadStringCompleted);
The doc of the API tells me to post like this:
Rate Limit: Yes
HTTP Methods: POST
Authentication: Basic authentication (Username or E-Mail and Password)
Formats: xml
Parameters: format, apikey [GET], activity_id [POST], activity_duration [POST], activity_kj [POST], timestamp [POST] (optional)
Does anyone see what’s wrong?
Shouldn’t you have a
?before stating query parameters instead of&http://jokr.info/api/v8/diary/add_item.xml?apikey=123456&item_id=1240&serving_id=1566