{"id":5526,"date":"2020-02-25T12:10:38","date_gmt":"2020-02-25T12:10:38","guid":{"rendered":"http:\/\/www.max-sperling.bplaced.net\/?p=5526"},"modified":"2024-02-16T10:25:59","modified_gmt":"2024-02-16T10:25:59","slug":"parameter-handling-rest-api-design","status":"publish","type":"post","link":"http:\/\/www.max-sperling.bplaced.net\/?p=5526","title":{"rendered":"Parameter handling (REST)"},"content":{"rendered":"<ul>\n<li><strong>Path-Param<\/strong> &#8230; Gets specified in the URL-Path to move down the hierarchy.<\/li>\n<li><strong>Query-Param<\/strong> &#8230; Gets specified behind the URL-Path to inject flat parameters.<\/li>\n<li><strong>Form-Param<\/strong> &#8230; Gets specified in the Message-Body to inject nested parameters.<\/li>\n<\/ul>\n<hr>\n<p><strong>Example with curl<\/strong><\/p>\n<p>1. Get all movies called Oldboy from 2003<br \/>\n&#8211;> Query-Param : \/movies?title=Oldboy&#038;year=2003<\/p>\n<pre>\r\n$ curl --request GET https:\/\/www.movdb.com\/movies?title=Oldboy&year=2003\r\n{\r\n}\r\n<\/pre>\n<p>2. Create that missing legendary movie<br \/>\n&#8211;> Form-Param: { &#8220;Name&#8221;: &#8220;Oldboy&#8221;, &#8220;Year&#8221;: 2003 }<\/p>\n<pre>\r\n$ curl --header 'content-type: application\/json' \\\r\n       --data '{ \"Name\": \"Oldboy\", \"Year\": 2003 }' \\\r\n       --request POST https:\/\/www.movdb.com\/movies\r\n{\r\n    \"Uri\": \"\/movies\/123456-oldboy\"\r\n    \"Name\": \"Oldboy\",\r\n    \"Year\": 2003,\r\n    \"Genre\": []\r\n}\r\n<\/pre>\n<p>3. Update the genre of the created movie<br \/>\n&#8211;> Path-Param: \/movies\/123456-oldboy<\/p>\n<pre>\r\n$ curl --header 'content-type: application\/json' \\\r\n       --data '{ \"Genre\": [ \"Action\", \"Drama\", \"Mystery\" ] }' \\\r\n       --request PATCH https:\/\/www.movdb.com\/movies\/123456-oldboy\r\n{\r\n    \"Uri\": \"\/movies\/123456-oldboy\"\r\n    \"Name\": \"Oldboy\",\r\n    \"Year\": 2003,\r\n    \"Genre\": [ \"Action\", \"Drama\", \"Mystery\" ]\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Path-Param &#8230; Gets specified in the URL-Path to move down the hierarchy. Query-Param &#8230; Gets specified behind the URL-Path to<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false},"categories":[27],"tags":[],"_links":{"self":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/5526"}],"collection":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5526"}],"version-history":[{"count":1,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/5526\/revisions"}],"predecessor-version":[{"id":16753,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/5526\/revisions\/16753"}],"wp:attachment":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5526"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5526"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5526"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}