How to design a multi-conditional query that follows the Restful API specification?

problem description

  1. due to following the Restful API specification, the Get request method is difficult to design interfaces for multi-conditional queries

the environmental background of the problems and what methods you have tried

someone has provided two ways

  1. http://localhost:8080/app/names?queryDtoStr={"query1":12,"query2":2,"query3":2}
  2. or request directly using POST

related codes

what result do you expect? What is the error message actually seen?

is there any other way of design? try to follow the Restful API specification


quoted in: RESTful API design best practices
original text: Best Practices for Designing a Pragmatic RESTful API

what if Action does not conform to the CRUD operation?

  1. restructure the Action, so that it looks like the field of a resource (I understand it as a partial field or partial field). This approach works when the Action does not contain parameters. For example, a valid action can be mapped to a Boolean type field, and resources can be updated through PATCH.
  2. uses the RESTful principle to treat it as if it were a child resource. For example, Github's API lets you star a gist, via PUT / gists/:id/star and unstar via DELETE / gists/:id/star .
  3. sometimes you just can't map Action to any meaningful RESTful structure. For example, multi-resource search cannot really map to any resource access point. In this case, / search would be very meaningful, although it is not a noun. There's no problem with this-you just need to do the right thing from the perspective of API consumers and make sure that everything you do is clearly documented to avoid confusion.

so the subject can provide / app/names/search service specifically for the search function, and the query parameters are generally passed through query parameters .


Restful query uses Get request, and parameter passing uses query string. Of course, you have to consider the size of your parameters. After all, Get passes parameters, and the content of parameters is limited.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e7e86a-467b6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e7e86a-467b6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?