Thank you for the module.
If I understood correctly this makes it possible to submit POST requests with Feeds (in addition to default GET requests), and add parameters to it. The question is: which type of parameters and how to write them in the form?

Example, I need to execute a request like this:

curl -X POST 'https://website/api/' \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: my_key' \
  --data-raw '{
    "address": "my_address"
  }'

and I tried to fill the Post parameters form both like this:

x-api-key: my_key 
address: my_address

and like this:

--header: 'x-api-key: my_key'
--data-raw: '{
    "address": "my_address"
  }'

but I don't get anything back.

I tested with Postman and it works, so I guess while the module Feeds_Fetcher_Headers let us provide headers, what is this module providing?
Documentation is lacking

Thanks!

CommentFileSizeAuthor
#6 feeds_fetcher_post.zip15.95 KBkopeboy

Comments

kopeboy created an issue. See original summary.

kopeboy’s picture

OK I was looking into /vendor/guzzlehttp/guzzle/src/RequestOptions.php
and there I can see you basically are just adding a way to set the query parameters with this module (which we can usually also just add in the URL no?).. am I right?

So I guess I could edit the module to use the form for editing the HEADER and BODY Guzzle RequestOptions instead of the FORM_PARAMS right?

Thank you

sleitner’s picture

@kopeboy with this module you can only add POST parameters (like your raw data) to the request, but no additional headers. Query parameters you can add by adding it to the URL.
If you want to modify the module for your needs, you have to add HEADERS and FORM_PARAMS arrays to the Guzzle request.

sleitner’s picture

Version: 1.0.0-alpha1 » 1.0.x-dev

@kopeboy Please check out commit 25366c6f0bcac67426b3eb40b3dd89e8d7894738 in 1.0.x branch

kopeboy’s picture

StatusFileSize
new15.95 KB

Thank you for the quick response and commit, but

Shouldn't I be adding the BODY to the Guzzle request?!

It is just a single field of raw data (multiple lines allowed), not an array of query parameters (rows to preg_match) like the ones you can directly put in the url.

Here is what I have

Unfortunately it is returning:

Warning message
The feed is empty.

and I don't understand why, since the same request is working in Postman and returning values :(

sleitner’s picture

@kopeboy the EmptyFeedException is thrown in the fetcher as well as in the parser. Please check your parser settings, especially the mapping context (with the help of an evaluator e.g. https://jsonpath.com/). Test the parser with an uploaded json file.

sleitner’s picture

Checkout commit ac6e159fa408d4e9a269c6599d711be510b9cdba in 1.0.x branch. You can now choose between FORM_PARAMS and BODY guzzle request options

kopeboy’s picture

Status: Active » Reviewed & tested by the community

Wow, it works like a charm, THANK YOU!
How may I contribute back?

sleitner’s picture

Status: Reviewed & tested by the community » Fixed

Thank you @kopeboy for making the module more versatile for everyone

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.