unfoldedcircle / feature-and-bug-tracker

Feature and bug tracker repository for Unfolded Circle products
24 stars 0 forks source link

[bug] get entities with rest api limited to 100 entities? #395

Closed Kat-CeDe closed 2 months ago

Kat-CeDe commented 2 months ago

Is there an existing issue for this?

Description

I have 126 entities but the rest api only allows to get 100. I tried pages from 1..200, 101..200 and 30..130 but always got an error.

With for instance the search option I can collect more if I know what is missing.

How to Reproduce

  1. Create a lot of entities (at least more than 100)
  2. Try to retrieve entities with rest api

I can attache a backup with 126 (?) entities if needed

Expected behavior

Also entity pages >100 (99?) can be trieved.

System version

1.8.0

What part of the system affected by the problem?

Core

Additional context

No response

martonborzak commented 2 months ago

Please provide the command you send and logs of the error.

Kat-CeDe commented 2 months ago

Command is: curl_setopt($ch, CURLOPT_URL, 'http://'.$IP2.'/api/entities?page=1&limit=130'); which is PHP up to limit=100 it is working. The Try option in the WebUI checks and says only 100 allowed.

The answer is: array(3) { ["code"]=> string(16) "VALIDATION_ERROR" ["message"]=> string(30) "limit: Invalid per_page number" ["errors"]=> array(1) { [0]=> array(2) { ["field"]=> string(5) "limit" ["field_errors"]=> array(1) { [0]=> array(3) { ["code"]=> string(5) "RANGE" ["message"]=> string(23) "Invalid per_page number" ["params"]=> array(2) { ["max"]=> float(100) ["min"]=> float(1) } } } } } }

In the debug log of core I only get the same: 2024-07-18 10:54:45.133412 +00:00 core WARN Error encountered while processing the incoming HTTP request: ValidationErrorDetailed(ValidationErrorMsg { code: "VALIDATION_ERROR", message: "limit: Invalid per_page number", errors: Some([ValidationErrorDetail { field: "limit", field_errors: Some([FieldValidationError { code: Some("RANGE"), message: "Invalid per_page number", params: Some({"max": Number(100.0), "min": Number(1.0)}) }]) }]) })

Is there a way to retrieve entities over 100 with knowing a query word or an ID?

Ralf

martonborzak commented 2 months ago

Paging works and it's documented in the docs. You can query 100 items per page. If you want to get the next page, you need to increase the page number and not the limit.

Kat-CeDe commented 2 months ago

When I use: curl -X 'GET' \ 'http://IP:PORT/api/entities?page=80&limit=50' \ -H 'accept: application/json'

I get an empty array as an answer: []

martonborzak commented 2 months ago

Let's say you have 230 entities. Then you get the first 100 by calling: api/entities?page=1&limit=100 Then the next 100: api/entities?page=2&limit=100 Then you get the remaining 30 by getting the 3rd page: api/entities?page=3&limit=100

This is pretty much standard paging, nothing special here.

Kat-CeDe commented 2 months ago

Thank you I thought with page was item number meant. Reading helps sometimes. A little excuse as you I am not native speaking.

martonborzak commented 2 months ago

No problem :)