Authentication failure when using kintone.api.url()

 I am using Kintone REST API Request to get JSON from the same domain of mine. I got an error message saying “{“code”: " CB_JH01”, “id”: “…”, “message”: “Authentication failed. X-Requested-With header is required for session authentication.”}

 

I am accessing another Kintone app in the same domain.

I follow Kintone’s official documentation. 

 

var params = {

       ‘app’: 17,

       ‘query’: ‘gp === ’ + record.gphidden.value + ’  limit 100 offset 0’,

         ‘fields’: [‘company’, ‘modelno’, ‘serialno’],

         ‘totalCount’: true

        };

 

kintone.api(kintone.api.url(’/k/v1/records’, true), ‘GET’, params).then(function (response) {

 

                var tableRecords = response.records;

 

        }, function (error) {

        });

Hi annaylee,

From the content of the request, I believe that the corresponding request is being executed within the kintone event, in which case I think that there will be no authentication error.
There might be a mistake in the query description, so if it occurs, I think it is a different error.

Therefore, it doesn’t seem like there is a process that outputs the error response.
So, it would be best to find out how you are checking the error.

In addition, I thought that if you look at the network tab in the query error and click on the corresponding request from the network tab,
the page that displays the corresponding message is displayed because the session authentication did not pass.

In addition to the error, I’m also wondering if the error in the operator can be fixed by changing the “====” to “=.”

Query Operators and Functions:
https://kintone.dev/en/docs/kintone/overview/query-string/#query-operators-and-functions

Could you check that out and see if that resolves the error?