0

I want to run a phonograph aggregation query from the API and don't manage to set the pageSize. When I run an aggregation query from Slate, I can set the pageSize Parameter to 0 which has the effect, that I get only the aggregation in the result.

Here the complete preview from Slate of my query:

{
    "extractors": {
        "result": "$"
    },
    "headers": {},
    "method": "POST",
    "path": "search/tables",
    "pathParams": {},
    "queryParams": {
        "pageSize": 0
    },
    "bodyJson": {
        "tableRids": [
            "ri.phonograph2.main.table.xxxx"
        ],
        "filter": {
            "type": "and",
            "and": []
        },
        "aggregations": {
            "distincCrit": {
                "terms": {
                    "field": "type.raw",
                    "order": {
                        "_term": "asc"
                    }
                }
            }
        }
    }
}

I want to perform this as well from the command-line in python. So I set up my code. The json-parameter is filled with the bodyJson from above.

response = requests.post(PHONOAPI_SEARCH_API, headers=HEADERS, json=searchAgg, verify=False, proxies=proxies).text

But I find no way to add the queryParams with the pageSize to my python Code.

Any suggestion?

I tried to add the pageSize Attribute to the json and the header without effect. I tried as well to pass the queryParams in the "data" parameter of the request but failed as well.

S.B
  • 13,077
  • 10
  • 22
  • 49
  • Did you try the params keyword argument? https://requests.readthedocs.io/en/latest/user/quickstart/#passing-parameters-in-urls – nicornk Nov 27 '22 at 19:22
  • Thanks @nicornk ! That was the trick. Please post this as the answer. Then I'll can give my credits – Kai Altstaedt Nov 29 '22 at 07:36

1 Answers1

0

You should be able to pass the pageSize using requests params keyword arguments:

response = requests.post(PHONOAPI_SEARCH_API, 
                         headers=HEADERS, 
                         json=searchAgg, 
                         params={"pageSize": 100}
                         )
nicornk
  • 654
  • 3
  • 11