将 XML 对象附加到 asp.net REST 入门工具包中的 REST POST
我第一次在 asp.net 中使用 REST 入门工具包,遇到了一些麻烦。
我创建了一些 XML...
String newOrganizationStrin = "<somexml></somexml>";
XmlDocument newOrganizationXml = new XmlDocument();
newOrganizationXml.LoadXml(newOrganizationString);
然后创建了一个 httpClient...
HttpClient http = new HttpClient("https://companyname.capsulecrm.com/api/");
http.TransportSettings.Credentials = new NetworkCredential("APIKEY", "PASSWORD");
现在我需要使用 http.POST() 将 xml 发布到正确的 URL。我认为我需要的重载方法是(string url, httpContent body)。所以我猜谜题中缺少的部分是如何将 xml 转换为 httpContent,我似乎无法实例化它。
有什么想法吗?
乔恩
I'm using the REST starter kit in asp.net for the first time and having a bit of trouble.
I've created some XML...
String newOrganizationStrin = "<somexml></somexml>";
XmlDocument newOrganizationXml = new XmlDocument();
newOrganizationXml.LoadXml(newOrganizationString);
Then I create an httpClient...
HttpClient http = new HttpClient("https://companyname.capsulecrm.com/api/");
http.TransportSettings.Credentials = new NetworkCredential("APIKEY", "PASSWORD");
Now I need to use http.POST() to post the xml to the correct URL. The overloaded method I need I think is (string url, httpContent body). So I guess the missing piece of the puzzle is how to convert the xml to an httpContent, which I can't seem to instantiate.
Any ideas?
Jon
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您真的从字符串开始,最简单的方法是
另一种方法是使用 XElement
If you are really starting with a string, the easiest way is
The other way is to use XElement
抱歉,刚刚找到答案 -
Sorry, just found the answer -