{"action":"created","issue":{"url":"https://api.github.com/repos/RESTful-Drupal/restful/issues/894","repository_url":"https://api.github.com/repos/RESTful-Drupal/restful","labels_url":"https://api.github.com/repos/RESTful-Drupal/restful/issues/894/labels{/name}","comments_url":"https://api.github.com/repos/RESTful-Drupal/restful/issues/894/comments","events_url":"https://api.github.com/repos/RESTful-Drupal/restful/issues/894/events","html_url":"https://github.com/RESTful-Drupal/restful/issues/894","id":147496035,"number":894,"title":"Profile2 and Users","user":{"login":"jshamley","id":1050828,"avatar_url":"https://avatars.githubusercontent.com/u/1050828?v=3","gravatar_id":"","url":"https://api.github.com/users/jshamley","html_url":"https://github.com/jshamley","followers_url":"https://api.github.com/users/jshamley/followers","following_url":"https://api.github.com/users/jshamley/following{/other_user}","gists_url":"https://api.github.com/users/jshamley/gists{/gist_id}","starred_url":"https://api.github.com/users/jshamley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jshamley/subscriptions","organizations_url":"https://api.github.com/users/jshamley/orgs","repos_url":"https://api.github.com/users/jshamley/repos","events_url":"https://api.github.com/users/jshamley/events{/privacy}","received_events_url":"https://api.github.com/users/jshamley/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-11T17:23:03Z","updated_at":"2016-04-12T04:00:15Z","closed_at":null,"body":"I am building out a RESTful API and am running into an issue trying to POST a new user with some Profile2 fields. I can GET the Profile2  fields using the code below, but I am unable to POST to them through the user. Since neither Profile2 or User uses an entity reference field, we can't use the [resource](https://github.com/RESTful-Drupal/restful/wiki/2.-Defining-the-public-fields-(2.x)#public-field-array-keys) property on the public fields. \r\n```\r\n<?php\r\n\r\n/**\r\n * @file\r\n * Contains \\Drupal\\bqe_restful\\Plugin\\resource\\user\\User__1_0.\r\n */\r\n\r\nnamespace Drupal\\bqe_restful\\Plugin\\resource\\user;\r\n\r\nuse Drupal\\restful\\Http\\RequestInterface;\r\nuse Drupal\\restful\\Plugin\\resource\\ResourceEntity;\r\nuse Drupal\\restful\\Plugin\\resource\\ResourceInterface;\r\n\r\n/**\r\n * Class Articles\r\n * @package Drupal\\restful\\Plugin\\resource\r\n *\r\n * @Resource(\r\n *   name = \"user:1.0\",\r\n *   resource = \"user\",\r\n *   label = \"User\",\r\n *   description = \"Export the User entity with cookie authentication.\",\r\n *   authenticationTypes = {\r\n *     \"basic_auth\"\r\n *   },\r\n *   authenticationOptional = TRUE,\r\n *   dataProvider = {\r\n *     \"entityType\": \"user\",\r\n *     \"bundles\": {\r\n *       \"user\"\r\n *     },\r\n *   },\r\n *   majorVersion = 1,\r\n *   minorVersion = 0\r\n * )\r\n */\r\nclass User__1_0 extends ResourceEntity implements ResourceInterface {\r\n\r\n  /**\r\n   * {@inheritdoc}\r\n   */\r\n  protected function publicFields() {\r\n    $public_fields = parent::publicFields();\r\n\r\n    $public_fields['username'] = array('property' => 'name');\r\n    unset($public_fields['label']);\r\n\r\n    $public_fields['roles'] = array('property' => 'roles');\r\n    $public_fields['status'] = array('property' => 'status');\r\n    $public_fields['mail'] = array('property' => 'mail');\r\n    $public_fields['first_name'] = array('property' => 'field_first_name');\r\n    $public_fields['last_name'] = array('property' => 'field_last_name');\r\n\r\n    $public_fields['profile'] = [\r\n      'property' => 'uid', \r\n      'process_callbacks' => [[$this, 'getProfile']]\r\n    ];\r\n    \r\n    return $public_fields;\r\n  }\r\n\r\n  public function getProfile($uid) {\r\n    $profile = profile2_load_by_user($uid);\r\n    return $profile;\r\n  }\r\n\r\n}\r\n```\r\n\r\nUltimately I'd like to be able to do this with one POST call, saving a user and saving the Profile2 fields that are available. If it is necessary to do 2 calls, I can do that but I'm able to assign the UID to the Profile2 object. `$public_fields['broker_user_account'] = array('property' => 'uid');` on the Profile2 side will throw the error `The property uid could not be found in profile2:broker.`.\r\n\r\nIs this even possible? Is there a way to see all available properties? I see the UID prop in the DB and in Devel, but it throws an error when I try to assign."},"comment":{"url":"https://api.github.com/repos/RESTful-Drupal/restful/issues/comments/208693282","html_url":"https://github.com/RESTful-Drupal/restful/issues/894#issuecomment-208693282","issue_url":"https://api.github.com/repos/RESTful-Drupal/restful/issues/894","id":208693282,"user":{"login":"e0ipso","id":1140906,"avatar_url":"https://avatars.githubusercontent.com/u/1140906?v=3","gravatar_id":"","url":"https://api.github.com/users/e0ipso","html_url":"https://github.com/e0ipso","followers_url":"https://api.github.com/users/e0ipso/followers","following_url":"https://api.github.com/users/e0ipso/following{/other_user}","gists_url":"https://api.github.com/users/e0ipso/gists{/gist_id}","starred_url":"https://api.github.com/users/e0ipso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/e0ipso/subscriptions","organizations_url":"https://api.github.com/users/e0ipso/orgs","repos_url":"https://api.github.com/users/e0ipso/repos","events_url":"https://api.github.com/users/e0ipso/events{/privacy}","received_events_url":"https://api.github.com/users/e0ipso/received_events","type":"User","site_admin":false},"created_at":"2016-04-12T04:00:15Z","updated_at":"2016-04-12T04:00:15Z","body":"You should create your resource for the profile entity and then connect from the user to that resource using the uid."}}