开发者

Converting cURL authentication to Java and retrieving & updating data using REST XML (Pt.2)

开发者 https://www.devze.com 2023-02-15 17:15 出处:网络
This is the second part of my question on converting cURL to Java The first part is titled: Converting cURL authentication to Java and retrieving & updating data using REST XML (Pt.1)

This is the second part of my question on converting cURL to Java The first part is titled:

Converting cURL authentication to Java and retrieving & updating data using REST XML (Pt.1)

Third, how can I implement update, create, and delete for the api in Java? For example:

  1. Update: curl -i -X PUT -H "Content-Type:application/xml" -H "Accept: application/xml" -d "<ticket><description>Take this description</description></ticket>" http://user:password@www.assembla.com/spaces/my_space_id/tickets/1
  2. Delete" curl -i -X DELETE -H "Accept: application/xml" http://user:password@www.assembla.com/spaces/my_space_id/tickets/1
  3. Create: curl -i -X POST -H "Content-Type:application/xml" -H "Accept: application/xml" -d "<ticket><summary>This is a Summary</sum开发者_运维百科mary><priority>3</priority></ticket>" the weblink

In other words, how can I convert these cURL code into Java?

I would really appreciate your help. Also, a good reference to do such stuff in Java will be awesome too.

Thanks.


Well, the official API usually helps: Assembla REST API

There is says that you need to use basic authentication.

For accessing REST in Java: Rest clients for Java?


you should be looking out for Apache HttpClient tutorials.

There's some Samplecode of a Android Rest Client application around, try searching for it. Also, I just discovered "resting". I haven't tried it, but might be worth a look.

Also watching the Developing Android REST client applications video from Google.io is recommended, as it is teaching some very important architectural basics and hints.

I placed a similar question some time ago, and got an answer here at Stackoverflow.

0

精彩评论

暂无评论...
验证码 换一张
取 消