【问题标题】:"not found" error calling mongohq rest api from windows phone从 Windows Phone 调用 mongohq rest api 时出现“未找到”错误
【发布时间】:2012-12-27 07:01:37
【问题描述】:

我在从 Windows Phone (7.1) 应用程序调用 mongohq REST API 时遇到问题。我发布到以下形式的 URL:

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

当从基于浏览器的 REST 客户端调用时,完全相同的 URL 适用于 GET 和 POST 请求。但是,当我使用 HttpWebRequest 或 WebClient 从 Windows Phone 应用程序 POST 或 GET 到该 URL 时,我得到一个奇怪的错误,简单地说“服务器返回响应:'未找到'”。我已经通过 mongohq 网站检查了有问题的数据库和集合,两者肯定都存在。我还可以看到从浏览器 REST 客户端添加的文档。我得到的异常的部分 sn-p 如下所示。

以前有没有人尝试过这个,或者在类似的情况下似乎出现了同样的错误?提前致谢。

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

【问题讨论】:

    标签: rest windows-phone mongohq


    【解决方案1】:

    您可以尝试将 User-Agent 欺骗为与桌面浏览器相同,看看是否会有所不同。

    【讨论】:

      【解决方案2】:

      我有类似的问题(wp7.8)。解决办法是:

      1. 将项目编译到您的设备。
      2. 停止调试
      3. 关闭手机上的应用(最好重启设备)
      4. 一切都像魅力一样))

      对我有帮助(我用过 RestClient 和 WebClient)

      希望对你也有帮助。

      问候。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-04-10
        • 1970-01-01
        • 1970-01-01
        • 2019-07-05
        • 1970-01-01
        • 1970-01-01
        • 2020-07-14
        相关资源
        最近更新 更多