0

I’m trying to migrate some data from a remote rest/api (json) using the plugin source url. Here is my current migration iml file. I created a content type 'produkt' to match the fields from the remote data. I also enabled the migrate_plus and migrate_tools


# Migration configuration for products.
id: product
label: 'Product'
migration_group: Products
# Here we define the migration source
source:
  plugin: url
  track_changes: true
  cache_counts: true
  data_fetcher_plugin: http
  data_parser_plugin: json
  urls: 'https://base_url/endpoint’
  item_selector: data/
  fields:
    -
      name: uuid
      label: 'uuid'
      selector: uuid

    -
     name: title
     label: 'title'
     selector: name

  ids:
    uuid:
      type: string


  authentication:
    plugin: oauth2
    grant_type: client_credentials
    base_uri: ‘base_url’
    token_url: '/oauth/token/'
    client_id: my_id
    client_secret: ‘my_client_secret’
  headers:
    Accept: 'application/json'
    Content-Type: 'application/json'

  destination:
    plugin: 'entity:node'

  process:
    type:
      plugin: default_value
      default_value: produkt

    title: name
    field_uuid: uuid

    sticky:
      plugin: default_value
      default_value: 0
    uid:
      plugin: default_value
      default_value: 0

  migration_dependencies:
    required: {}
    optional: {}

  dependencies:
    enforced:
      module:
        - migrate_products

Running the command drush ms
provides the following error:

‘Class 'Sainsburys\Guzzle\Oauth2\GrantType\ClientCredentials' not found in /usr/share/nginx/html/modules/contrib/migrate_plus/src/Plugin/migrate_plus/authentication/OAuth2.php’

Could some one help me try to understand what is happening or how I can handle this issue?

Thank you in advance

Update: I stopped trying to import from from the a http data_fetcher and switched to the file data_fetcher. My migration yml file looks now like this.


# Migration configuration for products.
id: product
label: 'Product'
migration_group: Products
# Here we define the migration source
source:
  plugin: url
  track_changes: true
  cache_counts: true
  data_fetcher_plugin: file
  data_parser_plugin: json
  include_raw_data: true
  urls: /sites/web/files/data/data.json
  item_selector: data
  fields:
    -
      name: uuid
      label: 'uuid'
      selector: uuid

    -
     name: title
     label: 'title'
     selector: name

  ids:
    uuid:
      type: string

  destination:
    plugin: entity:node

  process:
    type:
      plugin: default_value
      bundle: produkt

    title: name
    field_uuid: uuid

    sticky:
      plugin: default_value
      default_value: 0
    uid:
      plugin: default_value
      default_value: 0

  migration_dependencies:
    required: {}
    optional: {}

  dependencies:
    enforced:
      module:
        - migrate_products

After runing the drush drush ms, I got following ouput


file parser plugin: could not retrieve data from /sites/web/files/data/data.json
 Group: Products (Products)  Status  Total  Imported  Unprocessed  Last imported 
 product                     Idle    n. v.  0         n. v.

Could someone please help understand what is wrong with my migration file?

btw, that's how my json file looks like:


{
  "data": {
    "uuid": {
      "value": "ed64784-cjjhd6",
      "patient": false
    },
    "name": {
      "value": "Name",
      "patient": false
    },

How to specify the value of the uuid as ids? Thank you in advance

Sincerely

  • Your project is missing a library: packagist.org/packages/sainsburys/guzzle-oauth2-plugin – Clive Dec 19 '18 at 15:09
  • Hey @kiamlaluno: thank you for your quick response. Please can you tell me how I can add this library on my project? – Hermann Dec 19 '18 at 15:19
  • The comment was from @Clive. – kiamlaluno Dec 19 '18 at 15:41
  • install your modules with composer will download the required libraries like composer require 'drupal/migrate_plus:^4.0' – berramou Dec 19 '18 at 15:59
  • Hey @Clive, berramou, thank you for your answers guys. I will proceed that way. – Hermann Dec 19 '18 at 16:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.