“未找到"从 Windows 手机调用 mongohq rest api 时出错 [英] "not found" error calling mongohq rest api from windows phone

查看:57
本文介绍了“未找到"从 Windows 手机调用 mongohq rest api 时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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

推荐答案

您可以尝试将 User-Agent 伪装成与桌面浏览器相同的方式,看看是否有所不同.

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

这篇关于“未找到"从 Windows 手机调用 mongohq rest api 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆