# Httpjson pagination querystring value + 1

**URL:** <https://discuss.elastic.co/t/httpjson-pagination-querystring-value-1/307398>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [June 16, 2022, 11:30am UTC](https://discuss.elastic.co/t/httpjson-pagination-querystring-value-1/307398 "2022-06-16T11:30:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![frolko](https://avatars.discourse-cdn.com/v4/letter/f/50afbb/32.png) [@frolko](https://discuss.elastic.co/u/frolko)\
**Post date:** [June 16, 2022, 11:30am UTC](https://discuss.elastic.co/t/httpjson-pagination-querystring-value-1/307398/1 "2022-06-16T11:30:28Z")

</div>

Trying to use httpjson integration to scrape an api of data, using filebeat.8.2.2

The api takes query parameters PageSize=1000&PageNumber=1, where I'm supposed to keep adding PageNumber +1 until I get a 404 error.

However I can't figure out how to configure.

```auto
- set:
    target: url.params.PageNumber
    value: [[add .last_response.url.params.PageNumber 1]]
    fail_on_template_error: true

```

gives error: `[elastic_agent.filebeat][error] Error creating runner from config: fail to unpack the set configuration: type mismatch accessing 'response.pagination.0.set.value' accessing 'response'`

if I change value with a '

```auto
- set:
    target: url.params.PageNumber
    value: '[[add .last_response.url.params.PageNumber 1]]'
    fail_on_template_error: true

```

gives error: `[elastic_agent.filebeat][error] Error creating runner from config: fail to unpack the set configuration: type mismatch accessing 'response.pagination.0.set.value' accessing 'response'`

How can I set the pagination rules to keep increasing until done?  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/0/30e065e1f03288c3486658bafae6f24f43460abb.png)

---

<div class="post-metadata">

**Author:** ![TiagoQueiroz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tiagoqueiroz/32/107061_2.png) [@TiagoQueiroz](https://discuss.elastic.co/u/TiagoQueiroz)\
**Post date:** [June 17, 2022, 10:31am UTC](https://discuss.elastic.co/t/httpjson-pagination-querystring-value-1/307398/2 "2022-06-17T10:31:40Z")

</div>

Hi @frolko,

There are a couple of mistakes on your syntax:

1. To access the URL parameter you have to use the Get function: [[.last\_response.ur.params.Get "foo"]]
2. URL parameters are read as string, so you have to convert them to int before doing mathematical operations with it.

A fixed version of your configuration is:

```nohighlight
      - set:
          target: url.params.PageNumber
          value: '[[add (toInt (.last_response.url.params.Get "PageNumber")) 1]]'

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 15, 2022, 12:32pm UTC](https://discuss.elastic.co/t/httpjson-pagination-querystring-value-1/307398/3 "2022-07-15T12:32:24Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
