Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-20684

eZRest v2: Unable to update user object. Get 200 in return, but user object remain unchanged

    XMLWordPrintable

Details

    Description

      It seems impossible to update users via rest
      You'll get a 200 reply but the field values in the reply is the old values, not the new onces. Also, if you visit the user using admin interface, you'll still see the old field values

      This is the request

      #################### - Client request BEGIN - #########################
      PATCH /api/ezp/v2/user/users/59 HTTP/1.1
      Host: ezpublish5.rhel61.qa.ez.local:8080
      User-Agent: eZ REST QA Tester
      Content-Length: 516
      Authorization: Basic YWRtaW46cHVibGlzaA==
      Accept: application/vnd.ez.api.User+json
      Content-type: application/vnd.ez.api.UserUpdate+json
      
      {
        "UserUpdate": {
          "mainLanguageCode": "eng-GB",
          "Section": {
            "_href": "/content/sections/2"
          },
          "fields": {
            "field": [
            {
                "fieldDefinitionIdentifier": "first_name",
                "languageCode": "eng-GB",
                "fieldValue": "test First Name2"
              },{
                "fieldDefinitionIdentifier": "last_name",
                "languageCode": "eng-GB",
                "fieldValue": "test Last Name2"
              }
            ]
          },
          "email": "vl3(a)ez.no",
          "password": "testpass43",
        }
      }
      
      
      ##################### - Client request END - ##########################
      

      And this is the reply

      ##################### - Target reply BEGIN - ##########################
      HTTP/1.1 200 OK
      Date: Thu, 11 Apr 2013 14:21:11 GMT
      Server: Apache/2.2.15 (Red Hat)
      X-Powered-By: PHP/5.3.3
      Accept-Patch: application/vnd.ez.api.UserUpdate+json
      Cache-Control: no-cache
      X-Debug-Token: 5166c6d79e668
      Connection: close
      Transfer-Encoding: chunked
      Content-Type: application/vnd.ez.api.User+json
      
      b25
      {"User":{"_media-type":"application\/vnd.ez.api.User+json","_href":"\/api\/ezp\/v2\/user\/users\/59","_id":59,"_remoteId":"610778cc32660b08ea9a1cd34fcb6ab7","ContentType":{"_media-type":"application\/vnd.ez.api.ContentType+json","_href":"\/api\/ezp\/v2\/content\/types\/4"},"name":"test First Name1 test Last Name1","Versions":{"_media-type":"application\/vnd.ez.api.VersionList+json","_href":"\/api\/ezp\/v2\/content\/objects\/59\/versions"},"Section":{"_media-type":"application\/vnd.ez.api.Section+json","_href":"\/api\/ezp\/v2\/content\/sections\/2"},"MainLocation":{"_media-type":"application\/vnd.ez.api.Location+json","_href":"\/api\/ezp\/v2\/content\/locations\/1\/5\/13\/61"},"Locations":{"_media-type":"application\/vnd.ez.api.LocationList+json","_href":"\/api\/ezp\/v2\/content\/objects\/59\/locations"},"Owner":{"_media-type":"application\/vnd.ez.api.User+json","_href":"\/api\/ezp\/v2\/user\/users\/14"},"publishDate":"2013-04-11T15:47:51+02:00","lastModificationDate":"2013-04-11T15:47:51+02:00","mainLanguageCode":"eng-GB","alwaysAvailable":"false","Version":{"_media-type":"application\/vnd.ez.api.Version+json","_href":"\/api\/ezp\/v2\/content\/objects\/59\/versions\/1","VersionInfo":{"id":508,"versionNo":1,"status":"PUBLISHED","modificationDate":"2013-04-11T15:47:51+02:00","Creator":{"_media-type":"application\/vnd.ez.api.User+json","_href":"\/api\/ezp\/v2\/user\/users\/14"},"creationDate":"2013-04-11T15:47:51+02:00","initialLanguageCode":"eng-GB","languageCodes":"eng-GB","names":{"value":[{"_languageCode":"eng-GB","#text":"test First Name1 test Last Name1"}]},"Content":{"_media-type":"application\/vnd.ez.api.ContentInfo+json","_href":"\/api\/ezp\/v2\/content\/objects\/59"}},"Fields":{"field":[{"id":217,"fieldDefinitionIdentifier":"first_name","languageCode":"eng-GB","fieldValue":"test First Name1"},{"id":218,"fieldDefinitionIdentifier":"last_name","languageCode":"eng-GB","fieldValue":"test Last Name1"},{"id":219,"fieldDefinitionIdentifier":"user_account","languageCode":"eng-GB","fieldValue":{"hasStoredLogin":true,"contentId":59,"login":"testuser","email":"vl3(a)ez.no","passwordHash":"38588c00d20035cf90cfc45839955ddf","passwordHashType":"2","enabled":true,"maxLogin":0}},{"id":220,"fieldDefinitionIdentifier":"signature","languageCode":"eng-GB","fieldValue":null},{"id":221,"fieldDefinitionIdentifier":"image","languageCode":"eng-GB","fieldValue":null}]},"Relations":{"_media-type":"application\/vnd.ez.api.RelationList+json","_href":"\/api\/ezp\/v2\/content\/objects\/59\/versions\/1\/relations","Relation":[]}},"login":"testuser","email":"vl3(a)ez.no","enabled":"true","UserGroups":{"_media-type":"application\/vnd.ez.api.UserGroupList+json","_href":"\/api\/ezp\/v2\/user\/users\/59\/groups"},"Roles":{"_media-type":"application\/vnd.ez.api.RoleAssignmentList+json","_href":"\/api\/ezp\/v2\/user\/users\/59\/roles"}}}
      
      ###################### - Target reply END - ###########################
      

      This is the same reply in a more readable format, parsed by json_decode()

      string(6) "result"
      object(stdClass)#3008 (1) {
        ["User"]=>
        object(stdClass)#3009 (21) {
          ["_media-type"]=>
          string(32) "application/vnd.ez.api.User+json"
          ["_href"]=>
          string(25) "/api/ezp/v2/user/users/59"
          ["_id"]=>
          int(59)
          ["_remoteId"]=>
          string(32) "610778cc32660b08ea9a1cd34fcb6ab7"
          ["ContentType"]=>
          object(stdClass)#3028 (2) {
            ["_media-type"]=>
            string(39) "application/vnd.ez.api.ContentType+json"
            ["_href"]=>
            string(27) "/api/ezp/v2/content/types/4"
          }
          ["name"]=>
          string(32) "test First Name1 test Last Name1"
          ["Versions"]=>
          object(stdClass)#3027 (2) {
            ["_media-type"]=>
            string(39) "application/vnd.ez.api.VersionList+json"
            ["_href"]=>
            string(39) "/api/ezp/v2/content/objects/59/versions"
          }
          ["Section"]=>
          object(stdClass)#3013 (2) {
            ["_media-type"]=>
            string(35) "application/vnd.ez.api.Section+json"
            ["_href"]=>
            string(30) "/api/ezp/v2/content/sections/2"
          }
          ["MainLocation"]=>
          object(stdClass)#3026 (2) {
            ["_media-type"]=>
            string(36) "application/vnd.ez.api.Location+json"
            ["_href"]=>
            string(39) "/api/ezp/v2/content/locations/1/5/13/61"
          }
          ["Locations"]=>
          object(stdClass)#3019 (2) {
            ["_media-type"]=>
            string(40) "application/vnd.ez.api.LocationList+json"
            ["_href"]=>
            string(40) "/api/ezp/v2/content/objects/59/locations"
          }
          ["Owner"]=>
          object(stdClass)#3025 (2) {
            ["_media-type"]=>
            string(32) "application/vnd.ez.api.User+json"
            ["_href"]=>
            string(25) "/api/ezp/v2/user/users/14"
          }
          ["publishDate"]=>
          string(25) "2013-04-11T15:47:51+02:00"
          ["lastModificationDate"]=>
          string(25) "2013-04-11T15:47:51+02:00"
          ["mainLanguageCode"]=>
          string(6) "eng-GB"
          ["alwaysAvailable"]=>
          string(5) "false"
          ["Version"]=>
          object(stdClass)#3024 (5) {
            ["_media-type"]=>
            string(35) "application/vnd.ez.api.Version+json"
            ["_href"]=>
            string(41) "/api/ezp/v2/content/objects/59/versions/1"
            ["VersionInfo"]=>
            object(stdClass)#3022 (10) {
              ["id"]=>
              int(508)
              ["versionNo"]=>
              int(1)
              ["status"]=>
              string(9) "PUBLISHED"
              ["modificationDate"]=>
              string(25) "2013-04-11T15:47:51+02:00"
              ["Creator"]=>
              object(stdClass)#3023 (2) {
                ["_media-type"]=>
                string(32) "application/vnd.ez.api.User+json"
                ["_href"]=>
                string(25) "/api/ezp/v2/user/users/14"
              }
              ["creationDate"]=>
              string(25) "2013-04-11T15:47:51+02:00"
              ["initialLanguageCode"]=>
              string(6) "eng-GB"
              ["languageCodes"]=>
              string(6) "eng-GB"
              ["names"]=>
              object(stdClass)#3021 (1) {
                ["value"]=>
                array(1) {
                  [0]=>
                  object(stdClass)#3020 (2) {
                    ["_languageCode"]=>
                    string(6) "eng-GB"
                    ["#text"]=>
                    string(32) "test First Name1 test Last Name1"
                  }
                }
              }
              ["Content"]=>
              object(stdClass)#3014 (2) {
                ["_media-type"]=>
                string(39) "application/vnd.ez.api.ContentInfo+json"
                ["_href"]=>
                string(30) "/api/ezp/v2/content/objects/59"
              }
            }
            ["Fields"]=>
            object(stdClass)#3018 (1) {
              ["field"]=>
              array(5) {
                [0]=>
                object(stdClass)#3016 (4) {
                  ["id"]=>
                  int(217)
                  ["fieldDefinitionIdentifier"]=>
                  string(10) "first_name"
                  ["languageCode"]=>
                  string(6) "eng-GB"
                  ["fieldValue"]=>
                  string(16) "test First Name1"
                }
                [1]=>
                object(stdClass)#3017 (4) {
                  ["id"]=>
                  int(218)
                  ["fieldDefinitionIdentifier"]=>
                  string(9) "last_name"
                  ["languageCode"]=>
                  string(6) "eng-GB"
                  ["fieldValue"]=>
                  string(15) "test Last Name1"
                }
                [2]=>
                object(stdClass)#3015 (4) {
                  ["id"]=>
                  int(219)
                  ["fieldDefinitionIdentifier"]=>
                  string(12) "user_account"
                  ["languageCode"]=>
                  string(6) "eng-GB"
                  ["fieldValue"]=>
                  object(stdClass)#3012 (8) {
                    ["hasStoredLogin"]=>
                    bool(true)
                    ["contentId"]=>
                    int(59)
                    ["login"]=>
                    string(8) "testuser"
                    ["email"]=>
                    string(9) "vl3(a)ez.no"
                    ["passwordHash"]=>
                    string(32) "38588c00d20035cf90cfc45839955ddf"
                    ["passwordHashType"]=>
                    string(1) "2"
                    ["enabled"]=>
                    bool(true)
                    ["maxLogin"]=>
                    int(0)
                  }
                }
                [3]=>
                object(stdClass)#3011 (4) {
                  ["id"]=>
                  int(220)
                  ["fieldDefinitionIdentifier"]=>
                  string(9) "signature"
                  ["languageCode"]=>
                  string(6) "eng-GB"
                  ["fieldValue"]=>
                  NULL
                }
                [4]=>
                object(stdClass)#3007 (4) {
                  ["id"]=>
                  int(221)
                  ["fieldDefinitionIdentifier"]=>
                  string(5) "image"
                  ["languageCode"]=>
                  string(6) "eng-GB"
                  ["fieldValue"]=>
                  NULL
                }
              }
            }
            ["Relations"]=>
            object(stdClass)#3006 (3) {
              ["_media-type"]=>
              string(40) "application/vnd.ez.api.RelationList+json"
              ["_href"]=>
              string(51) "/api/ezp/v2/content/objects/59/versions/1/relations"
              ["Relation"]=>
              array(0) {
              }
            }
          }
          ["login"]=>
          string(8) "testuser"
          ["email"]=>
          string(9) "vl3(a)ez.no"
          ["enabled"]=>
          string(4) "true"
          ["UserGroups"]=>
          object(stdClass)#3005 (2) {
            ["_media-type"]=>
            string(41) "application/vnd.ez.api.UserGroupList+json"
            ["_href"]=>
            string(32) "/api/ezp/v2/user/users/59/groups"
          }
          ["Roles"]=>
          object(stdClass)#3010 (2) {
            ["_media-type"]=>
            string(46) "application/vnd.ez.api.RoleAssignmentList+json"
            ["_href"]=>
            string(31) "/api/ezp/v2/user/users/59/roles"
          }
        }
      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            vidar.langseid@ibexa.co Vidar Langseid
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 30 minutes
                1d 30m