Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post request params + support for functions #102

Open
pocin opened this issue Jul 23, 2018 · 1 comment
Open

Post request params + support for functions #102

pocin opened this issue Jul 23, 2018 · 1 comment

Comments

@pocin
Copy link

pocin commented Jul 23, 2018

this config

{
  "parameters": {
    "api": {
      "baseUrl": "https://httpbin.org",
      "pagination": {
        "method": "offset",
        "limit": 100,
        "limitParam": "size",
        "offsetParam": "from"}
    },
    "config": {
      "debug": true,
      "outputBucket": "my-bucket",
      "jobs": [
        {
          "endpoint": "/post",
          "method": "POST",
          "dataField": "data",
          "dataType": "raw_mentions",
          "params": {
              "filters": {
                  "period": {
                      "end": {
                          "function": "strtotime",
                          "args": [
                    "today"
                          ]
                      },
                      "shortcut": "last-1w"
                  }
              }
          }
        }
      ]
    }
  }
}

adds the pagination to the post parameters body

[2018-07-23 09:29:07] logger.DEBUG: Using no authentication. [] [] 
[2018-07-23 09:29:07] logger.DEBUG: POST /post HTTP/1.1 Host: httpbin.org User-Agent: Guzzle/5.3.1 curl/7.38.0 PHP/7.1.14 Content-Type: application/json Content-Length: 113 {"filters":{"period":{"end":{"function":"strtotime","args":["today"]},"shortcut":"last-1w"}},"size":100,"from":0} [] [] [2018-07-23 09:29:08] logger.DEBUG: Processing results for my-bucket. [] [] 
[2018-07-23 09:29:08] logger.INFO: Extractor finished successfully. [] [] 

Is this a bug or a feature? I would expect it to do a request like this

POST /post?size=100&from=0
Host: httpbin.org
---json payload here---
{"filters":{"period":{"end":{"function":"strtotime","args":["today"]},"shortcut":"last-1w"}

2nd thing - the function is not evaluated in the jobs[0].params + an attribute can't be referenced "params": {"attr": "my_attr"}.

The "params" is simply taken as is - which I understand why, but it's a big bummer. Is there a way around this?

@odinuv
Copy link
Member

odinuv commented Jul 24, 2018

it's a limitation of the design which sends params either to body or to URL. as for the second - off the top of my head - no idea - perhaps try support?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants