简体   繁体   English

Java Android中的cURL XML REST POST

[英]cURL XML REST POST in Java Android

How can I convert this statement in cURL curl -i -X POST -H "Content-Type:application/xml" -H "Accept: application/xml" -d "<ticket><summary>This is a Summary</summary><priority>3</priority></ticket>" http://user:password@www.assembla.com/spaces/my _space_id/tickets to Java in Android? 如何在cURL curl -i -X POST -H "Content-Type:application/xml" -H "Accept: application/xml" -d "<ticket><summary>This is a Summary</summary><priority>3</priority></ticket>" http://user:password@www.assembla.com/spaces/my _space_id/tickets转换此语句curl -i -X POST -H "Content-Type:application/xml" -H "Accept: application/xml" -d "<ticket><summary>This is a Summary</summary><priority>3</priority></ticket>" http://user:password@www.assembla.com/spaces/my _space_id/tickets转换为Android中的Java? The most important part is how to invoke the XML in the URL? 最重要的部分是如何在URL中调用XML?

Use HttpClient , specifically HttpPost for your POST request. 对您的POST请求使用HttpClient ,特别是HttpPost The -H switches turn into addHeader() calls. -H开关变成addHeader()调用。 You would probably just use a StringEntity for the XML payload, though I haven't tried a non-urlencoded POST with HttpClient before. 您可能只将StringEntity用作XML有效负载,尽管我之前从未尝试过使用HttpClient进行非StringEntity编码的POST。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM