# \[String can't be coerced into Integer\] when i call lastest.json API

**URL:** https://meta.discourse.org/t/string-cant-be-coerced-into-integer-when-i-call-lastest-json-api/221519
**Category:** Bug
**Tags:** rest-api
**Created:** [March 21, 2022, 6:42am UTC](https://meta.discourse.org/t/string-cant-be-coerced-into-integer-when-i-call-lastest-json-api/221519 "2022-03-21T06:42:45Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![dtc-thomas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dtc-thomas/32/337570_2.png) [@dtc-thomas](https://meta.discourse.org/u/dtc-thomas)
#### Post date: [March 21, 2022, 6:42am UTC](https://meta.discourse.org/t/string-cant-be-coerced-into-integer-when-i-call-lastest-json-api/221519/1 "2022-03-21T06:42:45Z")

</div>

When i call lastest.json?page=0&per\_page=10&foo=bar

```plaintext
     # TypeError:
     # String can't be coerced into Integer
     # ./lib/topic_query.rb:729:in `*'

```

[https://github.dev/discourse/discourse/blob/0832cad803bb429a49595eab822a7c77dfa2088b/lib/topic\_query.rb#L732-L737](https://github.dev/discourse/discourse/blob/0832cad803bb429a49595eab822a7c77dfa2088b/lib/topic_query.rb#L732-L737)  
I think can resolve by:

```plaintext
if options[:page]
  offset = options[:page].to_i * options[:per_page].to_i
  result = result.offset(offset) if offset > 0
end

```

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [March 21, 2022, 7:17am UTC](https://meta.discourse.org/t/string-cant-be-coerced-into-integer-when-i-call-lastest-json-api/221519/2 "2022-03-21T07:17:25Z")

</div>

This is a bit of a feature request, per\_page is not part of our API (not used by the client at all). This would not fully solve the issue cause per\_page would need to come with an upper limit of say maximum of 100-200.

Is there a specific reason you are looking to override page sizes?

---

<div class="post-metadata">

### Author: ![dtc-thomas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dtc-thomas/32/337570_2.png) [@dtc-thomas](https://meta.discourse.org/u/dtc-thomas)
#### Post date: [March 21, 2022, 7:27am UTC](https://meta.discourse.org/t/string-cant-be-coerced-into-integer-when-i-call-lastest-json-api/221519/3 "2022-03-21T07:27:18Z")

</div>

Yes, We have a customer page to get the topics with waterfall flow.  
Sure I think this is a feature request.  
We can use default per\_page and remove the per\_page query.
