Problem/Motivation

Using the Http data fetcher, there is no way to make a POST call to an API endpoint.

Proposed resolution

Using "method: 'POST'" or "method: 'GET'" in your migration definition along with data_fetcher_plugin: http, you should be able to define the type of call you'd like to make

Remaining tasks

Test attached patch, re-work if there is a better solution.

Data model changes

Migrations would still default to GET, but using the "method" parameter inside your source structure, you can change it to POST.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

swilmes created an issue. See original summary.

swilmes’s picture

deimos made their first commit to this issue’s fork.

deimos’s picture

Status: Active » Needs review

@swilmes Thanks for requesting this feature. I've just faced the same case when I need to request endpoint with POST method. Your approach looks good, I just reformat it a little bit (fork and MR is created).
Needs review and testing.

deimos’s picture

Assigned: Unassigned » deimos
Status: Needs review » Needs work
deimos’s picture

Assigned: deimos » Unassigned
Status: Needs work » Needs review
deimos’s picture

Assigned: Unassigned » deimos
Status: Needs review » Needs work
deimos’s picture

Assigned: deimos » Unassigned
Status: Needs work » Needs review
StatusFileSize
new1.26 KB

Set request method with more compact way.

juhaniemi’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the patch and elegant solution! I tested it, and it works like a charm.

heddn made their first commit to this issue’s fork.

  • heddn committed c0073abe on 6.0.x authored by deimos
    Issue #3352503 by deimos, swilmes, heddn: Allow HTTP fetcher to make...
heddn’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for your contributions.

Status: Fixed » Closed (fixed)

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

merilainen’s picture

Often POST requests require a body in the request. Is it possible now or should I create a ticket for that request?
Apparently it's possible configuring the request_options which are passed to Guzzle.
Here is an example of making a POST request to Alfresco API search endpoint:

  request_options:
    json:
      query:
        query: "ANCESTOR:\"workspace://SpacesStore/some-long-hash-id-value-here\" AND TYPE:\"cm:content\""
        language: lucene
      include:
        - properties
      fields:
        - modifiedAt
        - name
        - id