Question

I am having a problem calling the mongohq REST API from a windows phone (7.1) application. I POSTing to a URL of the following form:

https://api.mongohq.com/databases/[database]/collections/[collection]/documents?_apikey=XXXXXXXXXXX

Exactly the same URL, when called from a browser-based REST client works for both GET and POST requests. But when I POST or GET to that URL from a windows phone app using either HttpWebRequest or WebClient, I get back a weird error that says simply "the server returned the response:'not found'". I have examined the database and collection in question via the mongohq website, and both are certainly present. I can also see the documents that have been added from browser REST client. A partial snippet of the exception I am getting is shown below.

Has anyone tried this before, or seem the same error in a similar context? Thanks in advance.

System.Net.WebException: The remote server returned an error: NotFound. --->        System.Net.WebException: The remote server returned an error: NotFound.
   at System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
   at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClass2.<EndGetResponse>b__1(Object sendState)
   at System.Net.Browser.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>b__0(Object sendState)
   at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
   at S
Was it helpful?

Solution

You might try spoofing the User-Agent to be the same as a desktop browser and see if that makes a difference.

OTHER TIPS

I have similar problem (wp7.8). The solution is:

  1. Compile project to your device.
  2. Stop Debugging
  3. Close your app on phone (and better reboot device)
  4. All works like a charm))

It's help me (I used RestClient and WebClient)

I hope it's help you too.

Regards.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top