|
5 | 5 | "x-codeSamples": [
|
6 | 6 | {
|
7 | 7 | "lang": "Node + Request",
|
8 |
| - "source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/context',\n qs: {\n 'owner-id': 'c65b68ef-e73b-4bf2-be9a-7a322a9df150',\n 'page-token': 'next_page_token'\n },\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n" |
| 8 | + "source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/context',\n qs: {\n 'owner-id': 'c65b68ef-e73b-4bf2-be9a-7a322a9df150',\n 'page-token': 'next_page_token'\n },\n headers: {Circle-Token: '${CIRCLE_TOKEN}'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n" |
9 | 9 | },
|
10 | 10 | {
|
11 | 11 | "lang": "Python + Python3",
|
12 |
| - "source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/context?owner-id=c65b68ef-e73b-4bf2-be9a-7a322a9df150&page-token=next_page_token\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))" |
| 12 | + "source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'Circle-Token': \"$CIRCLE_TOKEN\" }\n\nconn.request(\"GET\", \"/api/v2/context?owner-id=c65b68ef-e73b-4bf2-be9a-7a322a9df150&page-token=next_page_token\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))" |
13 | 13 | },
|
14 | 14 | {
|
15 | 15 | "lang": "Go + Native",
|
16 |
| - "source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/context?owner-id=c65b68ef-e73b-4bf2-be9a-7a322a9df150&page-token=next_page_token\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Print
905C
ln(res)\n\tfmt.Println(string(body))\n\n}" |
| 16 | + "source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/context?owner-id=c65b68ef-e73b-4bf2-be9a-7a322a9df150&page-token=next_page_token\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"Circle-Token\", CIRCLE_TOKEN)\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}" |
17 | 17 | },
|
18 | 18 | {
|
19 | 19 | "lang": "Shell + Curl",
|
20 |
| - "source": "curl --request GET \\\n --url 'https://circleci.com/api/v2/context?owner-id=c65b68ef-e73b-4bf2-be9a-7a322a9df150&page-token=next_page_token' \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'" |
| 20 | + "source": "curl --request GET \\\n --url 'https://circleci.com/api/v2/context?owner-id=c65b68ef-e73b-4bf2-be9a-7a322a9df150&page-token=next_page_token' \\\n --header \"Circle-Token: $CIRCLE_TOKEN\"" |
21 | 21 | },
|
22 | 22 | {
|
23 | 23 | "lang": "Ruby + Native",
|
24 |
| - "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/context?owner-id=c65b68ef-e73b-4bf2-be9a-7a322a9df150&page-token=next_page_token\")\n\nhttp = Net::HTTP.new(url.host, url.port)\nhttp.use_ssl = true\nhttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\nrequest = Net::HTTP::Get.new(url)\nrequest[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" |
| 24 | + "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/context?owner-id=c65b68ef-e73b-4bf2-be9a-7a322a9df150&page-token=next_page_token\")\n\nhttp = Net::HTTP.new(url.host, url.port)\nhttp.use_ssl = true\nhttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\nrequest = Net::HTTP::Get.new(url)\nrequest[\"Circle-Token\"] = CIRCLE_TOKEN\n\nresponse = http.request(request)\nputs response.read_body" |
25 | 25 | }
|
26 | 26 | ]
|
27 | 27 | }
|
|
0 commit comments