Adding New Record to an app via web form with jQuery and ajax

I’m a bit of a novice with jQuery and ajax when it comes to sending data in json format to a REST API.  I have created a form and the underlying js to process the form fields into the correct json format.  However when I try to post the body and the header to the REST API I get the following errors in the console:

OPTIONS 405 (JSPs only permit GET POST or HEAD)

Failed to load Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘’ is therefore not allowed access. The response had HTTP status code 405.


Here is my js for the form and ajax:

$(document).ready(function() {

alert(‘jQuery is up and running!’)



//Array to hold field object data

varobjFieldLabel= {};

//Array to hold body object data that will be sent in a json body,

//this will contain field and value data via nested arrays

varobjBody= {};

//Set the application ID for Kintone json body

objBody[‘app’] =6;

//Serialize form data into an array


//Loop through the form data

$.each(objArray, function() {

//Array to hold value data that will be nested in the field label array

varobjValue= {};

if (objFieldLabel[] !==undefined) {

if (!objFieldLabel[].push) {

objFieldLabel[] = [objFieldLabel[]];


objValue[‘value’] =this.value||’’;



else {

objValue[‘value’] =this.value||’’;

objFieldLabel[] =objValue;



objBody[‘record’] =objFieldLabel;



$(’#your-form’).on(‘submit’, function(e) {






// beforeSend: function(xhr) {

// xhr.setRequestHeader(“X-Cybozu-API-Token”,“supersecretcodestring”),

// xhr.setRequestHeader(“X-HTTP-Method-Override”,“POST”),

// xhr.setRequestHeader(“Content-Type”,“application/json”);

// },

headers : {


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

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


contentType :‘application/json’,








// console.log(json);











Generally, webpages can’t access to other pages or APIs while you use JavaScript. If you don’t know that, please check this discussion.

So in order to submit data to the REST API on kintone I need to use a proxy for the API that is part of the allowed “Access-Control-Allow-Origin”.  Is there a list of API proxies that are allowed to interface with Kintone?

There is no public proxies and no list. If you want to access with JavaScript, I guess you have to prepare the corresponding functions as mentioned in the previous article.

Thanks Ryu,

Translate on the page is a bit of a mess but I get the general idea.  I have to create my own Web API and link to Lamdba then to kintone.  So just to be straight the restriction to submit data via an html page is limited to the JavaScript library.  So if I were to use PHP with cURL or Python I would be able to send the data then? 

If you do not mind javascript, you can also access kintone using PHP, Python or any other languages. And some libraries are available as follows.








In the end used PHP curl to submit the JSON data to Kintone to add records.  Thanks for the help.

Great works! Thank you for your polite report.

Hi Scott Shadler,

I am trying to PHP curl as well but did not have success. Can you please post your code here if you still have it. How you connected to Kintone. Did you use API Token or OAuth client? If you can give any help on this, that is great.Here is my code snippet, which is failing saying the Redirect URI is invalid

//Initialize a CURL session

//From URL to get webpage contents

curl_setopt($ch, CURLOPT_POST, 1);

//grab URL and pass it to the variable
curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

//Execute and get result
$result = curl_exec($ch);
die(“Connection Failure”);
echo $result;
echo $_GET[‘code’];