Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Views Bootstrap 5.5.4 — Minor update available for module views_bootstrap (5.5.4). Release: Rightup theme 1.0.3 — Minor update available for theme vartheme_bs5_rightup (1.0.3). Release: CommentOn 1.0.6 — Minor update available for module commenton (1.0.6). Release: ChatGPT Ads 1.0.3 — Minor update available for module chatgpt_ads (1.0.3). Release: Opensolr Search 5.1.3 — Minor update available for module opensolr_search (5.1.3). Release: ServiceM8 Webform Integration 1.2.1 — Minor update available for module servicem8_webform (1.2.1). Release: PostfixAdmin 1.0.0 — Initial release available for module postfix_admin (1.0.0)! Release: ip_analyser 1.0.3 — Minor update available for module ip_analyser (1.0.3). Module Revived: Swagger-PHP OpenAPI 3 documentation generator 1.0.0 — Module swagger_php updated after 10 months of inactivity (1.0.0). Security Coverage: Microsoft Azure AI — Module ai_provider_azure now has official Drupal security advisory coverage.

This module extends the Migrate Plus, Json Parser to interact with Drupal's JsonAPI.

When interacting with Drupal's JsonAPI there is a limit to the number of results that will be delivered. To get all results you have to make several requests, each time adjusting the page offset.

The Json Parser supplied with Migrate Plus requires the url parameter to supply an array of urls to query. But we do not know how many urls are needed to get all results.

Rather than supplying the migration source an array of urls, the JsonAPI parser will generate all urls necessary for the migration. This is done by supplying the JsonAPI parser the parameters necessary to construct the urls and adjust the offset value each time.

Example usage:

source:
  plugin: url
  data_fetcher_plugin: http
  data_parser_plugin: jsonapi
  item_selector: data
  jsonapi_host: {source host}
  jsonapi_prefix: '/jsonapi'
  jsonapi_endpoint: '/node/article'
  jsonapi_query_params:
    filter:
      default_langcode: 0
  jsonapi_langcodes:
    - ja
    - de
  urls: []

This will generate the following urls:

  • {source host}/ja/jsonapi/node/article?filter[default_langcode]=0&page[limit]=50&page[offset]=0
  • {source host}/ja/jsonapi/node/article?filter[default_langcode]=0&page[limit]=50&page[offset]=50
  • {source host}/ja/jsonapi/node/article?filter[default_langcode]=0&page[limit]=50&page[offset]=100
  • ...
  • {source host}/de/jsonapi/node/article?filter[default_langcode]=0&page[limit]=50&page[offset]=0
  • {source host}/de/jsonapi/node/article?filter[default_langcode]=0&page[limit]=50&page[offset]=50
  • {source host}/de/jsonapi/node/article?filter[default_langcode]=0&page[limit]=50&page[offset]=100
  • ...

The "page[offset]" parameter will increment by the "page[limit]" parameter value. until an empty result is returned.

By default these parameters are configured to work with Drupal's JsonAPI, but the names of these parameters can also be adjusted

source:
  jsonapi_query_param_keys:
    page_offset: 'offset'
    page_limit: 'items_per_page'
  prepend_langcode: FALSE

With the above example the query parameter for the page_offset will now be "offset" instead of "page[offset]".

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Dec 2023
Latest release
2 years ago
Releases (12 mo)
0
Maintenance
Dormant

Releases

Version Type Core Release date
1.1.x-dev Dev Dec 7, 2023
1.0.x-dev Dev Dec 7, 2023