Oh, I've done it ~. I feel like. I have written the fourth day today. I'm sorry. I would like to keep up with the traps that I tend to get hooked on. </ strong>
Actually, I was addicted to this problem at the Heroes League Ogaki Python Hackathon. It implements the wrong API token and URL location. This is the best trap. You must first realize that Kintone is really close to the framework for creating apps. Actually, I implemented it in Python this time, but the easiest one is Node.js. Because I was tied up with Python, my previous job in C # was actually Python, so I was able to work with Susui because I was learning. But what I made a mistake here is the location of the API key. @RyBB also points out. If you hurry, you will make a mistake.
kintone_output.py
#So far, everything is going well.
#The problem is from here.
#Where do you look?
#The URL behind the API token Curl.
URL =
#API tokens are often mistaken.
#Caution is required.
#I am also Node.I made a mistake when I was taught by js.
#Copy the part of the API token.
API_TOKEN =
#From here onward, there is no problem with normal code.
#If you make a mistake in the above two, it will hurt.
def get_kintone(url, api_token):
"Function to get all kintone records"
headers = {"X-Cybozu-API-Token": api_token}
resp = requests.get(url, headers=headers)
return resp
if __name__ == "__main__":
RESP = get_kintone(URL, API_TOKEN)
print(RESP.text)
nodejs:kintone.js
const kintone = require('@kintone/kintone-js-sdk');
//It's here.
//Please be careful.
//I was also addicted to it.
const domainName = 'SUB_DOMAIN.cybozu.com'; // Your kintone URL
//It's here.
//Please be careful.
const APIToken = 'YOUR_API_TOKEN'; // Your API Token
const appId = ○○; // AppID
const record = {
text: {
value: 'Text you want to add'
}
};
// Connection
const kintoneAuth = new kintone.Auth();
kintoneAuth.setApiToken({apiToken: APIToken});
const kintoneConnection = new kintone.Connection({domain: domainName, auth: kintoneAuth});
const kintoneRecord = new kintone.Record({connection: kintoneConnection});
// Add Record
kintoneRecord.addRecord({app: appId, record: record}).then((rsp) => {
console.log(rsp);
}).catch((err) => {
console.log(err.get());
});
If you pay attention to these two points, Kintone will be an invincible weapon in the hackathon. It's easier than messing around with the database. Everyone tends to run in the cloud, but in my case the hackathon is definitely Kintone. It is also invincible for hackathon map mashups.
Hmm. I will use Kinetone at the hackathon next year as well. @RyBB.
Recommended Posts