Skip to content

Instantly share code, notes, and snippets.

@ahandsel
Last active July 31, 2020 04:33
Show Gist options
  • Save ahandsel/ed9dee8fa39e634ea5da92beeaec8729 to your computer and use it in GitHub Desktop.
Save ahandsel/ed9dee8fa39e634ea5da92beeaec8729 to your computer and use it in GitHub Desktop.
Kintone Workshop REST API Commands

Kintone x Intro to REST API Workshop

Thank you for attending our event!

Download Links:

Sign-up for a Kintone Developer Program (KDP) Account:

Sign-up for a Developer License:

Open a Code Editor

Check how to start up your...

Symbols in cURL

Example cURL GET API Call:

curl -X GET 'https://devevents.kintone.com/k/v1/record.json' \
      -H 'X-Cybozu-API-Token: _Token_Here_' \
      -H 'Content-Type: application/json' \
      -d '{"app": 1, "id": 1}'

Breakdown of the Symbols

Symbol Meaning
curl command-line tool for transferring data
-X short for --request; used to set request method & endpoint
-H short for --header; used to set the header option
-d short for --data; used to set the body component
\ add a space & backslash to make a multi-line command
# In a single-line format:
curl -X GET 'https://devevents.kintone.com/k/v1/record.json' -H 'X-Cybozu-API-Token: E4MYYOKtoa1IjRpt0sSJeBscjd6oXPV6ueIZ2qFV' -H 'Content-Type: application/json' -d '{"app": 1, "id": 1}'
# In multi-line format:
curl -X GET 'https://devevents.kintone.com/k/v1/record.json'\
-H 'X-Cybozu-API-Token: E4MYYOKtoa1IjRpt0sSJeBscjd6oXPV6ueIZ2qFV'\
-H 'Content-Type: application/json'\
-d '{"app": 1, "id": 1}'
# Be sure to Insert your Subdomain, Token, App ID, and Record ID!
# In a single-line format:
curl -X GET 'https://INSERT_SUBDOMAIN.kintone.com/k/v1/record.json' -H 'X-Cybozu-API-Token: INSERT_TOKEN' -H 'Content-Type: application/json' -d '{"app": INSERT_APPID, "id": INSERT_RECORDID}'
# In multi-line format:
curl -X GET 'https://INSERT_SUBDOMAIN.kintone.com/k/v1/record.json'\
-H 'X-Cybozu-API-Token: INSERT_TOKEN'\
-H 'Content-Type: application/json'\
-d '{"app": INSERT_APPID, "id": INSERT_RECORDID}'
# Mac Terminal POST Template
# Be sure to Insert your Subdomain, Token, App ID, and Data!
# In a single-line format:
curl -X POST 'https://INSERT_SUBDOMAIN.kintone.com/k/v1/record.json' -H 'X-Cybozu-API-Token: INSERT_TOKEN' -H 'Content-Type: application/json' -d '{"app": INSERT_APPID, "record": {"name": {"value": "John Snow"}, "show": {"value": "Game of Thrones!"}}}'
# In multi-line format:
curl -X POST 'https://INSERT_SUBDOMAIN.kintone.com/k/v1/record.json' \
-H 'X-Cybozu-API-Token: INSERT_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"app": INSERT_APPID, "record": {"name": {"value": "John Snow"}, "show": {"value": "Game of Thrones!"}}}'
curl -X GET 'https://api.github.com/zen'
# Remember to insert your Github username & Personal Access Token
# Public
curl -X GET 'https://api.github.com/users/<USERNAME>'
# Private
curl -X GET 'https://api.github.com/users/<USERNAME>' -H 'Authorization: Token <INSERT_TOKEN>'

Symbols in PowerShell's Invoke-WebRequest

Example Invoke-WebRequest GET API Call

Invoke-WebRequest -Headers @{'X-Cybozu-API-Token' = 'E4MYYOKtoa1IjRpt0sSJeBscjd6oXPV6ueIZ2qFV'} `
  -Method GET `
  -Uri https://devevents.kintone.com/k/v1/record.json `
  -Body @{'app' = '1'; 'id'= '1'} `
  -OutFile GET_API_Output.txt

Breakdown of the Symbols

Symbol Meaning
Invoke-WebRequest cmdlets tool for transferring data
-Headers setting the header option
-Method setting the request method
-Uri setting the Endpoint component
-Body setting the body component
` add a space & grave accent for multi-line commands
@{…} saves the information as a hash table
-OutFile XYZ saves the output of the PowerShell command into the file named 'XYZ'
# The full JSON output is stored in the newly generated GET_API_Output.txt file
# In a single-line format:
Invoke-WebRequest -Headers @{'X-Cybozu-API-Token' = 'E4MYYOKtoa1IjRpt0sSJeBscjd6oXPV6ueIZ2qFV'} -Method GET -Uri https://devevents.kintone.com/k/v1/record.json -Body @{'app' = '1'; 'id'= '1'} -OutFile GET_API_Output.txt
# In multi-line format:
Invoke-WebRequest -Headers @{'X-Cybozu-API-Token' = 'E4MYYOKtoa1IjRpt0sSJeBscjd6oXPV6ueIZ2qFV'} `
-Method GET `
-Uri https://devevents.kintone.com/k/v1/record.json `
-Body @{'app' = '1'; 'id'= '1'} `
-OutFile GET_API_Output.txt
# Check the TLS version used:
[Net.ServicePointManager]::SecurityProtocol
# Set TLS 1.2 with the following command:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# Be sure to Insert your Subdomain, Token, App ID, and Record ID!
# In a single-line format:
Invoke-WebRequest -Headers @{'X-Cybozu-API-Token' = 'INSERT_TOKEN'} -Method GET -Uri https://INSERT_SUBDOMAIN.kintone.com/k/v1/record.json -Body @{'app' = 'INSERT_APPID'; 'id'= 'INSERT_RECORDID'} -OutFile GET_API_Output.txt
# In multi-line format:
Invoke-WebRequest -Headers @{'X-Cybozu-API-Token' = 'INSERT_TOKEN'} `
-Method GET `
-Uri https://INSERT_SUBDOMAIN.kintone.com/k/v1/record.json `
-Body @{'app' = 'INSERT_APPID'; 'id'= 'INSERT_RECORDID'} `
-OutFile GET_API_Output.txt
# Windows PowerShell POST Template
# Be sure to Insert your Subdomain, Token, App ID, and Data!
# In a single-line format:
Invoke-WebRequest –Headers @{'X-Cybozu-API-Token' = 'INSERT_TOKEN' ; 'Content-Type' = 'application/json'} –Method POST –Uri https://INSERT_SUBDOMAIN.kintone.com/k/v1/record.json –Body '{"app": INSERT_APPID, "record": {"name": {"value": "John Snow"}, "show": {"value": "Game of Thrones!"}}}'
# In multi-line format:
Invoke-WebRequest `
–Headers @{'X-Cybozu-API-Token' = 'INSERT_TOKEN' ; 'Content-Type' = 'application/json'} `
–Method POST –Uri https://INSERT_SUBDOMAIN.kintone.com/k/v1/record.json `
–Body '{"app": INSERT_APPID, "record": {"name": {"value": "John Snow"}, "show": {"value": "Game of Thrones!"}}}'
Invoke-WebRequest -Method GET -Uri https://api.github.com/zen
# Remember to insert your Github username & Personal Access Token
# Public
Invoke-WebRequest -Method GET -Uri https://api.github.com/users/<USERNAME>
# Private
Invoke-WebRequest -Headers @{'Authorization' = 'Token <PERSONAL ACCESS TOKEN>'} -Method GET -Uri https://api.github.com/users/<USERNAME>
Display the source blob
Display the rendered blob
Raw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment