What is REST call and how to send a REST call?

后端 未结 2 481
挽巷
挽巷 2020-12-13 09:51

I want to ask some questions about the REST call. I am the green for the REST call and I would like to like what is REST call and how to use the URL to send a REST call to t

相关标签:
2条回答
  • 2020-12-13 10:39

    REST is somewhat of a revival of old-school HTTP, where the actual HTTP verbs (commands) have semantic meaning. Til recently, apps that wanted to update stuff on the server would supply a form containing an 'action' variable and a bunch of data. The HTTP command would almost always be GET or POST, and would be almost irrelevant. (Though there's almost always been a proscription against using GET for operations that have side effects, in reality a lot of apps don't care about the command used.)

    With REST, you might instead PUT /profiles/cHao and send an XML or JSON representation of the profile info. (Or rather, I would -- you would have to update your own profile. :) That'd involve logging in, usually through HTTP's built-in authentication mechanisms.) In the latter case, what you want to do is specified by the URL, and the request body is just the guts of the resource involved.

    http://en.wikipedia.org/wiki/Representational_State_Transfer has some details.

    0 讨论(0)
  • 2020-12-13 10:41

    REST is just a software architecture style for exposing resources.

    • Use HTTP methods explicitly.
    • Be stateless.
    • Expose directory structure-like URIs.
    • Transfer XML, JavaScript Object Notation (JSON), or both.

    A typical REST call to return information about customer 34456 could look like:

    http://example.com/customer/34456
    

    Have a look at the IBM tutorial for REST web services

    0 讨论(0)
提交回复
热议问题