"unsupported query format" showed on some of the data in the query

Hello all,

I was trying to query the data (Product name) from an app to lookup in another app, which actually most of the product is found and the code is running smoothly. But the problem is that some of the product that have "#" (Hash sign) in it will not be able to running in the query, which I found out about this when I try to see all the level of error on console screen as example in the screenshot below.


*Error that I got and investigate.


*The Network query link that cut off after "#" sign in product name.


*The full product name that should be use in the previous query.

I'm guessing that the reason is the "#" sign cannot be used in the query process. If it's cannot can we have a way to fixed or workaround for this case, and if possible if there is other misunderstanding or reason please explain those for me. I'm not having much of basic information and detail with coding.

Thank you for all your answer.

2 Likes

Hello @Teerayook

You’re correct that special characters like # can cause issues when included in Kintone’s query parameters, particularly if they're not properly escaped. This is because # has a special meaning in URLs, so if it’s not handled correctly, the query string can be cut off or malformed.

To resolve this, one of the ways is instead of entering the query directly into a URL or script without processing, you’ll want to escape any special characters (like double quotes or backslashes) within the value and construct the query properly using JavaScript and Kintone’s JavaScript API.

Here’s an example of how to do it:

const query = 'Product = "' + productName.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"';

Then you can use the kintone.api() method like this:

kintone.api(kintone.api.url('/k/v1/records', true), 'GET', {
  app: YOUR_APP_ID,
  query: query,
  fields: ['Product']
});

This approach should allow you to safely search even for values that include special characters like #.

1 Like