can query parameters be mandatory in REST API

Satej :

I have a requirement which says there has to be two parameters(one of them represents date) that are part of the GET URI have to be mandatory. But these two parameters are only for filtration purpose. So my question is, Can mandatory parameters be used as Query params? (Or we can still use them as path params although there is no parent/child relationship)

Mollishree Soor :

Yes, mandatory parameters can be used in query parameters. In that case you need to put a validation after the API is hit to check whether the value of the parameter is not null and is of specified format. In case they fail to mention even the query parameter variable in the path, then they will end up receiving 400 error.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=403501&siteId=1