“not found” error calling mongohq rest api from windows phone

﹥>﹥吖頭↗ 提交于 2019-12-11 10:36:53

问题


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

回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/14050739/not-found-error-calling-mongohq-rest-api-from-windows-phone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!