Can I call an external API from within Kintone?

I’ve been trying to make a call to an external service as part of a test but I get nothing back, not even an error. Is this possible?

Hi Nathan

Can you share with us the code that you used? Thanks!

(function() {

const apiKey = "api key removed";
const feed = `https://newsapi.org/v2/everything?q=texas&apiKey=${apiKey}`;

let changeName = "txtName";

const news = () => {
return fetch(feed)
.then((resp) => {
if (resp.status === 200) {
return resp;
}
}).then(data => {
let topStory = data.json();
return topStory;
}).catch((err) => {
console.log(err);
});
};

var events = ["app.record.create.change." + changeName, 'app.record.edit.change.' + changeName];
let record;

news().then((data) => {
kintone.events.on(events, function(event) {
record = event.record;
console.log(record);
record[changeName].value = data.articles[0].title;
});
});

}());

There are several ways to run an external API, and Kintone provides an API that allows you to run external APIs.

 

Kintone.proxy ()
https://developer.kintone.io/hc/en-us/articles/213148917/

 

As for the details of the parameter, it depends on the API you are trying to run, so I am not sure exactly what you need in your case but hopefully kintone.proxy run the desired API you are working on.

Thanks Junko, I’ll check out the link and see how I get on.