Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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 the server. Can anyone give me some basic tutorial or link for my to reference?

Besides, if I want to send a REST call to the server, what should I do? Do I need to set something in the URL? or set something in the server? Thank you.

like image 612
Questions Avatar asked Oct 05 '10 07:10

Questions


People also ask

How do you do a REST call?

Step #1 – Enter the URL of the API in the textbox of the tool. Step #2 – Select the HTTP method used for this API (GET, POST, PATCH, etc). Step #3 – Enter any headers if they are required in the Headers textbox. Step #4 – Pass the request body of the API in a key-value pair.

What is meant by REST call?

REST is basically a set of rules for communication between a client and server. There are a few constraints on the definition of REST: Client-Server Architecture: the user interface of the website/app should be separated from the data request/storage, so each part can be scaled individually.

What is REST and how it works?

REST stands for Representational State Transfer. This means that when a client requests a resource using a REST API, the server transfers back the current state of the resource in a standardized representation.


2 Answers

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

like image 71
willcodejavaforfood Avatar answered Feb 09 '23 07:02

willcodejavaforfood


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.

like image 42
cHao Avatar answered Feb 09 '23 07:02

cHao