0

My current version of Drupal is 8.6.

In my account settings, one field named field_c_persion_tags is Entity reference and the type of item is Taxonmoy term.

In Views, I set a REST export(api/v1/getuserinfo), and in settings page:

Show:Entity
Fields:field_c_persion_tags

When I send a get REST api(api/v1/getuserinfo/7), it gives this response:

 "field_c_persion_tags":[
        {
            "target_id":4,
            "target_type":"taxonomy_term",
            "target_uuid":"e7fcf8b0-7503-4295-a2a5-bd2883b01fc0",
            "url":"/d86/taxonomy/term/4"
        },
        {
            "target_id":8,
            "target_type":"taxonomy_term",
            "target_uuid":"62348755-b2c8-4c1c-b126-27e3a2b2e739",
            "url":"/d86/taxonomy/term/8"
        }
    ],

But what I expect is as follows:

[
{
    "name":"user4",
    "field_c_persion_tags":"girl, gods",
    "uid":"7"
}

]

How should I configure it?



(I don't know how to upload the file)

Here is the whole yml file:

  uuid: c51261f3-51bb-4f7f-bcfa-334c5ecb457c
  langcode: en
  status: true
  dependencies:
    config:
      - field.storage.user.field_c_persion_tags
    module:
      - rest
      - serialization
      - user
  id: c_view_userinfo
  label: C_View_Userinfo
  module: views
  description: ''
  tag: ''
  base_table: users_field_data
  base_field: uid
  core: 8.x
  display:
    default:
      display_plugin: default
      id: default
      display_title: Master
      position: 0
      display_options:
        access:
          type: perm
          options:
            perm: 'access user profiles'
        cache:
          type: tag
          options: {  }
        query:
          type: views_query
          options:
            disable_sql_rewrite: false
            distinct: false
            replica: false
            query_comment: ''
            query_tags: {  }
        exposed_form:
          type: basic
          options:
            submit_button: Apply
            reset_button: false
            reset_button_label: Reset
            exposed_sorts_label: 'Sort by'
            expose_sort_order: true
            sort_asc_label: Asc
            sort_desc_label: Desc
        pager:
          type: mini
          options:
            items_per_page: 10
            offset: 0
            id: 0
            total_pages: null
            expose:
              items_per_page: false
              items_per_page_label: 'Items per page'
              items_per_page_options: '5, 10, 25, 50'
              items_per_page_options_all: false
              items_per_page_options_all_label: '- All -'
              offset: false
              offset_label: Offset
            tags:
              previous: ‹‹
              next: ››
        style:
          type: serializer
        row:
          type: fields
          options:
            inline: {  }
            separator: ''
            hide_empty: false
            default_field_elements: true
        fields:
          name:
            id: name
            table: users_field_data
            field: name
            relationship: none
            group_type: group
            admin_label: ''
            label: ''
            exclude: false
            alter:
              alter_text: false
              text: ''
              make_link: false
              path: ''
              absolute: false
              external: false
              replace_spaces: false
              path_case: none
              trim_whitespace: false
              alt: ''
              rel: ''
              link_class: ''
              prefix: ''
              suffix: ''
              target: ''
              nl2br: false
              max_length: 0
              word_boundary: false
              ellipsis: false
              more_link: false
              more_link_text: ''
              more_link_path: ''
              strip_tags: false
              trim: false
              preserve_tags: ''
              html: false
            element_type: ''
            element_class: ''
            element_label_type: ''
            element_label_class: ''
            element_label_colon: false
            element_wrapper_type: ''
            element_wrapper_class: ''
            element_default_classes: true
            empty: ''
            hide_empty: false
            empty_zero: false
            hide_alter_empty: true
            click_sort_column: value
            type: user_name
            settings:
              link_to_entity: false
            group_column: value
            group_columns: {  }
            group_rows: true
            delta_limit: 0
            delta_offset: 0
            delta_reversed: false
            delta_first_last: false
            multi_type: separator
            separator: ', '
            field_api_classes: false
            entity_type: user
            entity_field: name
            plugin_id: field
          field_c_persion_tags:
            id: field_c_persion_tags
            table: user__field_c_persion_tags
            field: field_c_persion_tags
            relationship: none
            group_type: group
            admin_label: ''
            label: ''
            exclude: false
            alter:
              alter_text: false
              text: ''
              make_link: false
              path: ''
              absolute: false
              external: false
              replace_spaces: false
              path_case: none
              trim_whitespace: false
              alt: ''
              rel: ''
              link_class: ''
              prefix: ''
              suffix: ''
              target: ''
              nl2br: false
              max_length: 0
              word_boundary: true
              ellipsis: true
              more_link: false
              more_link_text: ''
              more_link_path: ''
              strip_tags: false
              trim: false
              preserve_tags: ''
              html: false
            element_type: ''
            element_class: ''
            element_label_type: ''
            element_label_class: ''
            element_label_colon: false
            element_wrapper_type: ''
            element_wrapper_class: ''
            element_default_classes: true
            empty: ''
            hide_empty: false
            empty_zero: false
            hide_alter_empty: true
            click_sort_column: target_id
            type: entity_reference_entity_view
            settings:
              view_mode: default
            group_column: target_id
            group_columns: {  }
            group_rows: true
            delta_limit: 0
            delta_offset: 0
            delta_reversed: false
            delta_first_last: false
            multi_type: separator
            separator: ', '
            field_api_classes: false
            plugin_id: field
          uid:
            id: uid
            table: users_field_data
            field: uid
            relationship: none
            group_type: group
            admin_label: ''
            label: ''
            exclude: false
            alter:
              alter_text: false
              text: ''
              make_link: false
              path: ''
              absolute: false
              external: false
              replace_spaces: false
              path_case: none
              trim_whitespace: false
              alt: ''
              rel: ''
              link_class: ''
              prefix: ''
              suffix: ''
              target: ''
              nl2br: false
              max_length: 0
              word_boundary: true
              ellipsis: true
              more_link: false
              more_link_text: ''
              more_link_path: ''
              strip_tags: false
              trim: false
              preserve_tags: ''
              html: false
            element_type: ''
            element_class: ''
            element_label_type: ''
            element_label_class: ''
            element_label_colon: false
            element_wrapper_type: ''
            element_wrapper_class: ''
            element_default_classes: true
            empty: ''
            hide_empty: false
            empty_zero: false
            hide_alter_empty: true
            click_sort_column: value
            type: number_integer
            settings:
              thousand_separator: ''
              prefix_suffix: true
            group_column: value
            group_columns: {  }
            group_rows: true
            delta_limit: 0
            delta_offset: 0
            delta_reversed: false
            delta_first_last: false
            multi_type: separator
            separator: ', '
            field_api_classes: false
            entity_type: user
            entity_field: uid
            plugin_id: field
        filters:
          status:
            value: '1'
            table: users_field_data
            field: status
            plugin_id: boolean
            entity_type: user
            entity_field: status
            id: status
            expose:
              operator: ''
            group: 1
        sorts: {  }
        header: {  }
        footer: {  }
        empty: {  }
        relationships: {  }
        arguments:
          uid:
            id: uid
            table: users_field_data
            field: uid
            relationship: none
            group_type: group
            admin_label: ''
            default_action: ignore
            exception:
              value: all
              title_enable: false
              title: All
            title_enable: false
            title: ''
            default_argument_type: fixed
            default_argument_options:
              argument: ''
            default_argument_skip_url: false
            summary_options:
              base_path: ''
              count: true
              items_per_page: 25
              override: false
            summary:
              sort_order: asc
              number_of_records: 0
              format: default_summary
            specify_validation: false
            validate:
              type: none
              fail: 'not found'
            validate_options: {  }
            break_phrase: false
            not: false
            entity_type: user
            entity_field: uid
            plugin_id: user_uid
        display_extenders: {  }
      cache_metadata:
        max-age: -1
        contexts:
          - 'languages:language_content'
          - 'languages:language_interface'
          - request_format
          - url
          - url.query_args
          - user.permissions
        tags:
          - 'config:field.storage.user.field_c_persion_tags'
    rest_export_1:
      display_plugin: rest_export
      id: rest_export_1
      display_title: 'REST export'
      position: 1
      display_options:
        display_extenders: {  }
        path: api/v1/getuserinfo
        pager:
          type: some
          options:
            items_per_page: 10
            offset: 0
        style:
          type: serializer
          options:
            uses_fields: true
            formats:
              json: json
        row:
          type: data_entity
          options: {  }
        fields:
          name:
            id: name
            table: users_field_data
            field: name
            entity_type: user
            entity_field: name
            label: ''
            alter:
              alter_text: false
              make_link: false
              absolute: false
              trim: false
              word_boundary: false
              ellipsis: false
              strip_tags: false
              html: false
            hide_empty: false
            empty_zero: false
            plugin_id: field
            relationship: none
            group_type: group
            admin_label: ''
            exclude: false
            element_type: ''
            element_class: ''
            element_label_type: ''
            element_label_class: ''
            element_label_colon: true
            element_wrapper_type: ''
            element_wrapper_class: ''
            element_default_classes: true
            empty: ''
            hide_alter_empty: true
            click_sort_column: value
            type: user_name
            settings: {  }
            group_column: value
            group_columns: {  }
            group_rows: true
            delta_limit: 0
            delta_offset: 0
            delta_reversed: false
            delta_first_last: false
            multi_type: separator
            separator: ', '
            field_api_classes: false
          field_c_persion_tags:
            id: field_c_persion_tags
            table: user__field_c_persion_tags
            field: field_c_persion_tags
            relationship: none
            group_type: group
            admin_label: ''
            label: ''
            exclude: false
            alter:
              alter_text: false
              text: ''
              make_link: false
              path: ''
              absolute: false
              external: false
              replace_spaces: false
              path_case: none
              trim_whitespace: false
              alt: ''
              rel: ''
              link_class: ''
              prefix: ''
              suffix: ''
              target: ''
              nl2br: false
              max_length: 0
              word_boundary: true
              ellipsis: true
              more_link: false
              more_link_text: ''
              more_link_path: ''
              strip_tags: false
              trim: false
              preserve_tags: ''
              html: false
            element_type: ''
            element_class: ''
            element_label_type: ''
            element_label_class: ''
            element_label_colon: false
            element_wrapper_type: ''
            element_wrapper_class: ''
            element_default_classes: true
            empty: ''
            hide_empty: false
            empty_zero: false
            hide_alter_empty: true
            click_sort_column: target_id
            type: entity_reference_label
            settings:
              link: true
            group_column: target_id
            group_columns: {  }
            group_rows: true
            delta_limit: 0
            delta_offset: 0
            delta_reversed: false
            delta_first_last: false
            multi_type: separator
            separator: ', '
            field_api_classes: false
            plugin_id: field
          delta:
            id: delta
            table: user__field_c_persion_tags
            field: delta
            relationship: none
            group_type: group
            admin_label: ''
            label: ''
            exclude: false
            alter:
              alter_text: false
              text: ''
              make_link: false
              path: ''
              absolute: false
              external: false
              replace_spaces: false
              path_case: none
              trim_whitespace: false
              alt: ''
              rel: ''
              link_class: ''
              prefix: ''
              suffix: ''
              target: ''
              nl2br: false
              max_length: 0
              word_boundary: true
              ellipsis: true
              more_link: false
              more_link_text: ''
              more_link_path: ''
              strip_tags: false
              trim: false
              preserve_tags: ''
              html: false
            element_type: ''
            element_class: ''
            element_label_type: ''
            element_label_class: ''
            element_label_colon: false
            element_wrapper_type: ''
            element_wrapper_class: ''
            element_default_classes: true
            empty: ''
            hide_empty: false
            empty_zero: false
            hide_alter_empty: true
            set_precision: false
            precision: 0
            decimal: .
            separator: ','
            format_plural: false
            format_plural_string: !!binary MQNAY291bnQ=
            prefix: ''
            suffix: ''
            plugin_id: numeric
        defaults:
          fields: false
      cache_metadata:
        max-age: -1
        contexts:
          - 'languages:language_content'
          - 'languages:language_interface'
          - request_format
          - url
          - user.permissions
        tags:
          - 'config:field.storage.user.field_c_persion_tags'
    rest_export_2:
      display_plugin: rest_export
      id: rest_export_2
      display_title: 'REST export 2'
      position: 2
      display_options:
        display_extenders: {  }
        path: api/v2/getuserinfo
        row:
          type: data_field
          options:
            field_options:
              name:
                alias: ''
                raw_output: false
              field_c_persion_tags:
                alias: ''
                raw_output: false
        style:
          type: serializer
          options:
            formats:
              json: json
        title: 'get json of user'
        defaults:
          title: false
          query: false
        query:
          type: views_query
          options:
            disable_sql_rewrite: false
            distinct: false
            replica: false
            query_comment: ''
            query_tags: null
      cache_metadata:
        max-age: -1
        contexts:
          - 'languages:language_content'
          - 'languages:language_interface'
          - request_format
          - url
          - user.permissions
        tags:
          - 'config:field.storage.user.field_c_persion_tags'
    rest_export_3:
      display_plugin: rest_export
      id: rest_export_3
      display_title: 'REST export 22'
      position: 2
      display_options:
        display_extenders: {  }
        path: api/v22/getuserinfo
        row:
          type: data_field
          options:
            field_options:
              name:
                alias: ''
                raw_output: false
              field_c_persion_tags:
                alias: ''
                raw_output: false
        style:
          type: serializer
          options:
            formats:
              json: json
        title: 'get json of user'
        defaults:
          title: false
          query: false
        query:
          type: views_query
          options:
            disable_sql_rewrite: false
            distinct: false
            replica: false
            query_comment: ''
            query_tags: null
        display_description: ''
      cache_metadata:
        max-age: -1
        contexts:
          - 'languages:language_content'
          - 'languages:language_interface'
          - request_format
          - url
          - user.permissions
        tags:
          - 'config:field.storage.user.field_c_persion_tags'

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.