{"__v":0,"_id":"55fc9b813c21291900e7e10f","category":{"__v":1,"_id":"55fc9b7a3c21291900e7e0da","pages":["55fc9b813c21291900e7e109","55fc9b813c21291900e7e10a","55fc9b813c21291900e7e10b","55fc9b813c21291900e7e10c","55fc9b813c21291900e7e10d","55fc9b813c21291900e7e10e","55fc9b813c21291900e7e10f"],"project":"5553d36165e8260d0024419a","version":"55fc9b793c21291900e7e0d7","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-05-13T22:52:06.479Z","from_sync":false,"order":2,"slug":"creating-api-calls","title":"Creating API Calls"},"parentDoc":null,"project":"5553d36165e8260d0024419a","user":"5553d33065e8260d00244199","version":{"__v":12,"_id":"55fc9b793c21291900e7e0d7","project":"5553d36165e8260d0024419a","createdAt":"2015-09-18T23:17:13.545Z","releaseDate":"2015-09-18T23:17:13.545Z","categories":["55fc9b7a3c21291900e7e0d8","55fc9b7a3c21291900e7e0d9","55fc9b7a3c21291900e7e0da","55fc9b7a3c21291900e7e0db","55fc9b7a3c21291900e7e0dc","55fc9b7a3c21291900e7e0dd","55fc9b7a3c21291900e7e0de","55fc9b7a3c21291900e7e0df","55fc9b7a3c21291900e7e0e0","55fc9b7a3c21291900e7e0e1","55fc9b7a3c21291900e7e0e2","55fc9b7a3c21291900e7e0e3","55fc9bad4c80910d00b9bece","56394a0c3539050d00082122","56394a2f68b11f0d0048c9ff","56394a462fc5520d001a4db3","56394a4c2fc5520d001a4db4","56394a5b049e420d00476b5c","56394a6a2fc5520d001a4db5","56394f791593e4190073a44b","567b3adfb56bac0d0019d8d9","569d590e5a2b060d008741eb","569ea93dffccd10d00a05c7f"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"2.0.0","version":"2"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-05-17T23:58:10.932Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":6,"body":"From the Preview Pane for any API Call there is an option to see the HTTP call itself or, from from the drop down list, to pick from a variety of code options.\n\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/YnVD0U9THiDOUoYLeLRq_facebook_share_preview.png\",\n        \"facebook_share_preview.png\",\n        \"818\",\n        \"203\",\n        \"#b03a51\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nUsing the dropdown from the Preview option:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/RQcsg8BuTFuDSntFhHRO_Code%20Options.png\",\n        \"Code Options.png\",\n        \"165\",\n        \"200\",\n        \"#30408f\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nThe preview pane will then show the call as source code in the selected language.\n\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/QgE7nu20RqauZz1pByTl_sourcecode.png\",\n        \"sourcecode.png\",\n        \"816\",\n        \"452\",\n        \"#2b385a\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nThe code generated looks like this:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"URL url = new URL(\\\"https://graph.facebook.com/me/feed\\\"); \\nHttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();\\n\\ntry {\\n   urlConnection.setRequestMethod(\\\"POST\\\");\\n   urlConnection.setRequestProperty(\\\"Content-Length\\\", \\\"106\\\");\\n   urlConnection.setRequestProperty(\\\"Accept\\\", \\\"application/json\\\");\\n   urlConnection.setRequestProperty(\\\"User-Agent\\\", \\\"AppEngine-Google; (+http://code.google.com/appengine; appid: s~viatests)\\\");\\n   urlConnection.setRequestProperty(\\\"Host\\\", \\\"graph.facebook.com\\\");\\n   urlConnection.setRequestProperty(\\\"Content-Type\\\", \\\"application/x-www-form-urlencoded\\\");\\n   urlConnection.setRequestProperty(\\\"Authorization\\\", \\\"Bearer CAACTZAarW6x0BAAtzWDMqDRh0mnYRu5r7vcrSZBmwlzlJGFuX7bFV47GZCdyCut4u7MfIVfHNf0Bp1DaY70XdVXvnRSYK5ZC6MOSTuatOBZA7VSVnTF6u5dtXPYKZCaWIsoZBLszlZA3rluJjEfPgMs8J6ZApqAS0kk2oiZBndJW7YStkgZBdZCCxfmcmDxBTHnRlAEw4XK8ZAbIslLBtBl2ALs13\\\");\\n   \\n \\n   urlConnection.setDoOutput(true);\\n   urlConnection.setChunkedStreamingMode(0);\\n \\n   OutputStream out = new BufferedOutputStream(urlConnection.getOutputStream());\\n   writeStream(out);\\n\\n   InputStream in = new BufferedInputStream(urlConnection.getInputStream());\\n   readStream(in);\\n} finally {\\n   urlConnection.disconnect();\\n}\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]","excerpt":"Automated code generation from API calls","slug":"reference-code-generation","type":"basic","title":"Reference Code Generation"}

Reference Code Generation

Automated code generation from API calls

From the Preview Pane for any API Call there is an option to see the HTTP call itself or, from from the drop down list, to pick from a variety of code options. [block:image] { "images": [ { "image": [ "https://files.readme.io/YnVD0U9THiDOUoYLeLRq_facebook_share_preview.png", "facebook_share_preview.png", "818", "203", "#b03a51", "" ] } ] } [/block] Using the dropdown from the Preview option: [block:image] { "images": [ { "image": [ "https://files.readme.io/RQcsg8BuTFuDSntFhHRO_Code%20Options.png", "Code Options.png", "165", "200", "#30408f", "" ] } ] } [/block] The preview pane will then show the call as source code in the selected language. [block:image] { "images": [ { "image": [ "https://files.readme.io/QgE7nu20RqauZz1pByTl_sourcecode.png", "sourcecode.png", "816", "452", "#2b385a", "" ] } ] } [/block] The code generated looks like this: [block:code] { "codes": [ { "code": "URL url = new URL(\"https://graph.facebook.com/me/feed\"); \nHttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();\n\ntry {\n urlConnection.setRequestMethod(\"POST\");\n urlConnection.setRequestProperty(\"Content-Length\", \"106\");\n urlConnection.setRequestProperty(\"Accept\", \"application/json\");\n urlConnection.setRequestProperty(\"User-Agent\", \"AppEngine-Google; (+http://code.google.com/appengine; appid: s~viatests)\");\n urlConnection.setRequestProperty(\"Host\", \"graph.facebook.com\");\n urlConnection.setRequestProperty(\"Content-Type\", \"application/x-www-form-urlencoded\");\n urlConnection.setRequestProperty(\"Authorization\", \"Bearer CAACTZAarW6x0BAAtzWDMqDRh0mnYRu5r7vcrSZBmwlzlJGFuX7bFV47GZCdyCut4u7MfIVfHNf0Bp1DaY70XdVXvnRSYK5ZC6MOSTuatOBZA7VSVnTF6u5dtXPYKZCaWIsoZBLszlZA3rluJjEfPgMs8J6ZApqAS0kk2oiZBndJW7YStkgZBdZCCxfmcmDxBTHnRlAEw4XK8ZAbIslLBtBl2ALs13\");\n \n \n urlConnection.setDoOutput(true);\n urlConnection.setChunkedStreamingMode(0);\n \n OutputStream out = new BufferedOutputStream(urlConnection.getOutputStream());\n writeStream(out);\n\n InputStream in = new BufferedInputStream(urlConnection.getInputStream());\n readStream(in);\n} finally {\n urlConnection.disconnect();\n}", "language": "java" } ] } [/block]