# API를 통해 Data Explorer에 매개변수를 전달하려면 값을 따옴표로 묶어야 합니다

**URL:** <https://meta.discourse.org/t/passing-params-to-data-explorer-using-api-requires-enclosing-a-value/322843>\
**Category:** Bug\
**Tags:** data-explorer, rest-api\
**Created:** [8월 22, 2024, 8:35오전 UTC](https://meta.discourse.org/t/passing-params-to-data-explorer-using-api-requires-enclosing-a-value/322843 "2024-08-22T08:35:01Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Overgrow](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/overgrow/32/478189_2.png) [@Overgrow](https://meta.discourse.org/u/Overgrow)\
**Post date:** [8월 22, 2024, 8:35오전 UTC](https://meta.discourse.org/t/passing-params-to-data-explorer-using-api-requires-enclosing-a-value/322843/1 "2024-08-22T08:35:01Z")

</div>

참고: [Run Data Explorer queries with the Discourse API](https://meta.discourse.org/t/run-data-explorer-queries-with-the-discourse-api/120063)

> [@Discourse](#):
>
> `-F 'params={"viewed_at":"2019-06-10"}'`

API를 통해 SQL 쿼리에 매개변수를 전달할 때, Discourse는 현재 모든 값이 이중 인용부호로 감싸져 있어야 합니다. 이는 일부 시스템(특히 PHP의 `json_encode`)에서는 기본적으로 감싸지지 않는 정수 값도 포함됩니다. [JSON RFC](http://www.faqs.org/rfcs/rfc7159.html)를 살펴보면, 정수에 이중 인용부호를 사용할 의무는 없습니다. 이러한 요구 사항은 또한 "수용할 때는 관대하게…"라는 철학에도 어긋납니다.

재현 방법?

`-F 'params={"user_id":2}'`

서버가 500 Internal Server Error를 반환합니다.

에러 로그에는 다음과 같이 표시됩니다:

```plaintext
NoMethodError (undefined method `downcase' for 2:Integer)
app/controllers/application_controller.rb:424:in `block in with_resolved_locale'
app/controllers/application_controller.rb:424:in `with_resolved_locale'
lib/middleware/omniauth_bypass_middleware.rb:64:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/csp_script_nonce_injector.rb:12:in `call'
config/initializers/008-rack-cors.rb:14:in `call'
lib/freedom_patches/rails_rack_logger_from_rails_7_2.rb:35:in `call_app'
lib/freedom_patches/rails_rack_logger_from_rails_7_2.rb:22:in `call'
config/initializers/100-quiet_logger.rb:20:in `call'
config/initializers/100-silence_logger.rb:29:in `call'
lib/middleware/missing_avatars.rb:22:in `call'
lib/middleware/turbo_dev.rb:31:in `call'
lib/middleware/processing_request.rb:12:in `call'

Backtrace

plugins/discourse-data-explorer/lib/discourse_data_explorer/parameter.rb:121:in `cast_to_ruby'
...

```

이 형식은 올바르게 작동합니다:

`-F 'params={"user_id":"2"}'`

나는 예민해서 이렇게 공유하는 것이 아니라, 저와 유사한 문제를 겪을 수 있는 누군가의 시간을 절약해주고 싶어서입니다. 문제의 원인을 파악하는 데 시간이 좀 걸렸습니다.

---

_[View the full topic](https://meta.discourse.org/t/passing-params-to-data-explorer-using-api-requires-enclosing-a-value/322843)._
