3rd Party Data retrieval

Hi, I have made a custom code using ajax and i wanted to retrieve the data from my kintone app. is there something missing or wrong with my code? I can’t seem to find it and I’m stuck here for 3 days already.

Thank you

> No Access-Control-Allow-Origin header is present on the requested resource. Origin ‘xxxx’ is therefore not allowed access.

 

As shown in console, kintone doesn’t allow access from other subdomain.

So, you have to use “kintone.proxy()” if you want to access to other services or domains as follows.

 

var url = ‘https://hogehoge.kintone.com/k/v1/records.json’;

var method = ‘POST’;

var headers = {

  ‘Content-Type’:‘application/json’,

  ‘X-Cybozu-API-Token’:‘apitoken’,

  ‘X-HTTP-Method-Override’:‘GET’

};

var params = {

  app:54

};

kintone.proxy(url, method, headers, params).then(function(r){

  console.log(r);

}).catch(function(e){

  console.log(e);

});

Hi, Ryu Yamashita

Thank you for the response but i need to get the records from outside kintone. as of now I am using virtual host of xampp, I’m creating a website from scratch. is that possible to fetch them through Ajax?

Thank you.

If the global IP address or DNS is assigned to your website, you can access to your site through “kintone.proxy()” as well.

I think you have to set “Access-Control-Allow-Origin” into XAMPP if you want to access via ajax though I’m not familiar with XAMPP.

how will my program (scratch website using html, css, javascript) use the “kintone.proxy()” method? here are some of the errors that I have encountered and also the code

German, where are you executing this code from?

I think Ryu pointed out a solution that would only work if you were executing from kintone Domain A to get data from kintone Domain B
(the kintone.proxy() method can only be used inside the kintone domain)

Hi, Akira

I’m executing this code from a scratch application.

languages used:
HTML5
CSS3
Javascript

Here is the dir of my project for you to get familiar with

Root Folder

CSS folder

JS folder

Do you think this is possible? one more thing. my Project Manager wanted to use AWS (Amazon Web Services) but as of now we doesn’t have an account for that and he told me to study how to Insert, Delete, Update on kintone externally using their API for our future projects and also what I’m doing right now is for one of our client.

Sorry. I think I misunderstood as Akira pointed out.

 

Generally, webpages can’t access to other pages or APIs while you use JavaScript. “Access-Control-Allow-Origin”  needs to be set in the API received side via JavaScript. That condition is also called cross domain restriction. kintone denies cross-domain access as well.

 

On the other hand, as your project manager said, you can access from your website to kintone with JavaScript if you use Amazon API Gateway and AWS Lambda. You can control “Access-Control-Allow-Origin” in API Gateway.

This page show the sample settings and codes though it is in Japanse.

http://qiita.com/ha_ru_ma_ki/items/ccb7c535d8ef1b255365

Thank you for the support, Mr. Ryu Yamashita and Mr. Akira

I’m really satisfied with the service. I have solved my problems as of now, after getting the AWS account that my Project Manager wants to order and if I have questions I would love to have a conversation again regarding Kintone matters and for our future projects. Again, Thank you for the warm response ^^

Cheers,
German L. Manalili