# 一括取取得（GET）のエラーについて

**URL:** <https://community.cybozu.dev/t/topic/5988>\
**Category:** kintone 開発相談\
**Created:** [May 14, 2022, 5:01am UTC](https://community.cybozu.dev/t/topic/5988 "2022-05-14T05:01:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Legacy\_Account393](https://avatars.discourse-cdn.com/v4/letter/l/ecc23a/32.png) [@Legacy\_Account393](https://community.cybozu.dev/u/Legacy_Account393)\
**Post date:** [May 14, 2022, 5:01am UTC](https://community.cybozu.dev/t/topic/5988/1 "2022-05-14T05:01:06Z")

</div>

javascriptの初心者です。RESTAPIを用いて、外部サイトからキントーンアプリのある項目からｸｴﾘｰを作成して、関連レコード（１件）を取得したのちに、その中の項目（ここでは 文字列\_\_1行\_\_2 ） を取得するプログラムを作成しています。以下のプログラムです。

ただしプログラムを実行すると（サブドメインとID／PWはマスクしています）、エラーになります。  
コンソール上のエラーメッセージを見ると、『入力内容が正しくありません』とあり、続けて、idの項目に『必須です』と表示されています。今回のプログラムはIdの指定では無いのですが、idを要求されているのでしょうか？idを入力せずに、queryのパラメータでレコード取得を成功させるにはどうしたらよいでしょうか？  
よろしくお願いします。（CORS対策は実施済の前提でお願いします）

&nbsp;

&nbsp; alert(‘start’);

&nbsp; var appId = 13;  
&nbsp; var idpw = ‘xxxxxxxxxxxx’;  
&nbsp; const id\_encoded = btoa(idpw);  
&nbsp; var &nbsp;odID = 2420;  
&nbsp;&nbsp; var MyQuery = ‘数値\_5=’ + odID;  
&nbsp; var MyQuery2 = encodeURI(MyQuery);  
&nbsp; var params2 = ‘?app=’ + appId + ‘&query=’ + MyQuery2;

&nbsp; var url = ‘[https://xxxxxx.cybozu.com/k/v1/record.json](https://xxxxxx.cybozu.com/k/v1/record.json)’ + params2;

&nbsp; var xhr = new XMLHttpRequest();  
&nbsp; xhr.open(‘GET’, url);  
&nbsp; xhr.setRequestHeader(‘X-Cybozu-Authorization’,id\_encoded);  
&nbsp; xhr.setRequestHeader(‘X-Requested-With’,‘XMLHttpRequest’);

&nbsp; xhr.onload = function() {  
&nbsp; &nbsp; if (xhr.status === 200) {  
&nbsp; &nbsp; &nbsp; // success  
&nbsp; &nbsp; &nbsp; console.log(JSON.parse(xhr.responseText));  
&nbsp; &nbsp; &nbsp; var jsonobj = JSON.parse(xhr.responseText);  
&nbsp; &nbsp; &nbsp; alert(‘品名：’ + jsonobj.record.文字列\_\_1行\_\_2.value);  
&nbsp; &nbsp; } else {  
&nbsp; &nbsp; &nbsp; // error  
&nbsp; &nbsp; &nbsp; console.log(JSON.parse(xhr.responseText));  
&nbsp; &nbsp; &nbsp; var jsonobj = JSON.parse(xhr.responseText);  
&nbsp; &nbsp; &nbsp; alert(‘コード:’ + jsonobj.code);  
&nbsp; &nbsp; &nbsp; alert(‘メッセージ:’ + jsonobj.message);  
&nbsp; &nbsp; }  
&nbsp; };

&nbsp; xhr.send();

---

<div class="post-metadata">

**Author:** ![Legacy\_Account1517](https://avatars.discourse-cdn.com/v4/letter/l/4bbf92/32.png) [@Legacy\_Account1517](https://community.cybozu.dev/u/Legacy_Account1517)\
**Post date:** [May 14, 2022, 6:18am UTC](https://community.cybozu.dev/t/topic/5988/2 "2022-05-14T06:18:52Z")

</div>

ここはよく間違いやすいのですが、 records になります。

&nbsp;var url = ‘[https://xxxxxx.cybozu.com/k/v1/records.json](https://xxxxxx.cybozu.com/k/v1/records.json)’ + params2;

&nbsp;

---

<div class="post-metadata">

**Author:** ![Legacy\_Account393](https://avatars.discourse-cdn.com/v4/letter/l/ecc23a/32.png) [@Legacy\_Account393](https://community.cybozu.dev/u/Legacy_Account393)\
**Post date:** [May 14, 2022, 6:51am UTC](https://community.cybozu.dev/t/topic/5988/3 "2022-05-14T06:51:33Z")

</div>

recordsに変更したところ、エラーがなくなり、レスポンスも取得できました。ありがとうございました。（昨日に引き続き、ありがとうございました。）
