RESTful API - Correct behaviour when spurious/not requested parameters are passed in the request

后端 未结 6 1907
余生分开走
余生分开走 2020-12-13 14:50

We are developing a RESTful api that accepts query parameters in the request in the form of JSON encoded data.

We were wondering what is the correct behaviour when <

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-13 15:07

    I will suggest that you ignore the extra parameters. Reusing API is a game changer in the integration world. What if the same API can be used by other integration but with slightly extra parameters?

    Application A expecting:

    {
        "name": "Jeff",
        "surname": "Atwood"
    }
    

    Application B expecting:

    {
        "name": "Jeff",
        "surname": "Atwood",
        "color": "red"
    }
    

    Simple get application application A to ignore "color" will do the job rather to have 2 different API to handle that.

提交回复
热议问题