Skip to main content
added 155 characters in body
Source Link
John
  • 783
  • 2
  • 7
  • 22

I noticed that there are couple of ways one can use to get a resource using rest API. I am currently trying to find a valid pros/cons on each of these technique in order to adopt them at the larger scale.

What would be the main differences between these requests? Why would I add id into the path, and not into querystring or request body? Does it have to do with caching or only with resource centered conventions?

[HttpGet]
http://doamin.com/resources/{id}/?filter1=a,filter2=b,
or
http://doamin.com/resources/?filter1=a,filter2=b,id=500

instead of

[HttpPost]
http://doamin.com/resources

Body
{
id: 100,
filter1: "a",
filter2: "b"
}

or

[HttpPost]
    http://doamin.com/resources/{id}
    
    Body
    {
    filter1: "a",
    filter2: "b"
    }

I find it much more easier to develop endpoints using Post, but I would really like to consider possible issues a developer who will consume these endpoints would actually have.

I noticed that there are couple of ways one can use to get a resource using rest API. I am currently trying to find a valid pros/cons on each of these technique in order to adopt them at the larger scale.

What would be the main differences between these requests? Why would I add id into the path, and not into querystring or request body? Does it have to do with caching or only with resource centered conventions?

[HttpGet]
http://doamin.com/resources/{id}/?filter1=a,filter2=b,
or
http://doamin.com/resources/?filter1=a,filter2=b,id=500

instead of

[HttpPost]
http://doamin.com/resources

Body
{
id: 100,
filter1: "a",
filter2: "b"
}

I find it much more easier to develop endpoints using Post, but I would really like to consider possible issues a developer who will consume these endpoints would actually have.

I noticed that there are couple of ways one can use to get a resource using rest API. I am currently trying to find a valid pros/cons on each of these technique in order to adopt them at the larger scale.

What would be the main differences between these requests? Why would I add id into the path, and not into querystring or request body? Does it have to do with caching or only with resource centered conventions?

[HttpGet]
http://doamin.com/resources/{id}/?filter1=a,filter2=b,
or
http://doamin.com/resources/?filter1=a,filter2=b,id=500

instead of

[HttpPost]
http://doamin.com/resources

Body
{
id: 100,
filter1: "a",
filter2: "b"
}

or

[HttpPost]
    http://doamin.com/resources/{id}
    
    Body
    {
    filter1: "a",
    filter2: "b"
    }

I find it much more easier to develop endpoints using Post, but I would really like to consider possible issues a developer who will consume these endpoints would actually have.

edited title
Link
John
  • 783
  • 2
  • 7
  • 22

Structuring a GET/POT callPOST request to retrieve data using rest API

Source Link
John
  • 783
  • 2
  • 7
  • 22

Structuring a GET/POT call to retrieve data using rest API

I noticed that there are couple of ways one can use to get a resource using rest API. I am currently trying to find a valid pros/cons on each of these technique in order to adopt them at the larger scale.

What would be the main differences between these requests? Why would I add id into the path, and not into querystring or request body? Does it have to do with caching or only with resource centered conventions?

[HttpGet]
http://doamin.com/resources/{id}/?filter1=a,filter2=b,
or
http://doamin.com/resources/?filter1=a,filter2=b,id=500

instead of

[HttpPost]
http://doamin.com/resources

Body
{
id: 100,
filter1: "a",
filter2: "b"
}

I find it much more easier to develop endpoints using Post, but I would really like to consider possible issues a developer who will consume these endpoints would actually have.