Parameter handling (REST)

  • Path-Param … Gets specified in the URL-Path to move down the hierarchy.
  • Query-Param … Gets specified behind the URL-Path to inject flat parameters.
  • Form-Param … Gets specified in the Message-Body to inject nested parameters.

Example with curl

1. Get all movies called Oldboy from 2003
–> Query-Param : /movies?title=Oldboy&year=2003

$ curl --request GET https://www.movdb.com/movies?title=Oldboy&year=2003
{
}

2. Create that missing legendary movie
–> Form-Param: { “Name”: “Oldboy”, “Year”: 2003 }

$ curl --header 'content-type: application/json' \
       --data '{ "Name": "Oldboy", "Year": 2003 }' \
       --request POST https://www.movdb.com/movies
{
    "Uri": "/movies/123456-oldboy"
    "Name": "Oldboy",
    "Year": 2003,
    "Genre": []
}

3. Update the genre of the created movie
–> Path-Param: /movies/123456-oldboy

$ curl --header 'content-type: application/json' \
       --data '{ "Genre": [ "Action", "Drama", "Mystery" ] }' \
       --request PATCH https://www.movdb.com/movies/123456-oldboy
{
    "Uri": "/movies/123456-oldboy"
    "Name": "Oldboy",
    "Year": 2003,
    "Genre": [ "Action", "Drama", "Mystery" ]
}