Error occurs while updating a user via Portal API using PUT on Users resource
search cancel

Error occurs while updating a user via Portal API using PUT on Users resource


Article ID: 102353


Updated On:


CA API Management SaaS CA API Gateway


The user needs to update an API Portal (SaaS) User via PAPI.

In detail, they want to change its role from OrgAdmin (RoleId: 00000005-0005-0005-0005-000000000005) to Developer (RoleId: 00000006-0006-0006-0006-000000000006).
They followed both the instructions stated in the documentation (PUT on /Users resource) and also the info found in the PAPI page. Anyway, we obtained an error while updating the user; here are the details about the PUT request and the error obtained.

- Endpoint: https://<Portal_Host>/Users('18a7348f-e30f-4f9b-a0c3-36acf93ff489') 
- Payload: 

"Uuid": "18a7348f-e30f-4f9b-a0c3-36acf93ff489", 
"FirstName": "XXX", 
"LastName": "YYY", 
"Username": "XXXYYYTest", 
"Email": "", 
"RoleUuid": "00000006-0006-0006-0006-000000000006", 
"OrganizationUuid": "0297a922-8f21-4932-b7f9-60564c6ed7f6", 
"NotifyUser": true, 
"Locale": "en", 
"Status": "ENABLED" 

- HTTP Status: 500 
- Payload: 

"error" : { 
"code" : "ServerErrorException", "message" : { 
"lang" : "en-US", "value" : "Internal Server Error" 



Portal (SaaS)


User is basically trying to update the last orgAdmin of the organisation to a developer of the same organisation.
This is not allowed and hence the papi apis fail with a http status code 500. 

However the development is working on changing the http status code from 500 to 4XX, and a more intuitive response message. 

* In addition, while updating a orgAdmin or a developer, the field "RoleName": "devorgadministrators" or "RoleName": "developers" respectively is a mandatory field and should be present in the body of the request.
* If the request body does not have the above "RoleName" field. Hence the request fails every time with a 500 (Internal Server Error. Certain fields are missing from the request.).
* Had the user provided the field "RoleName": "devorgadministrators" in the payload, he would have got the exact error, which would have been
  400 (Unable to change the role of the last orgadmin in an organization to a developer user).

* However, since the Model Schema, present on the page, does not mention about the ‘”RoleName” : “String”’ field, the user would have
   ignored the field.
* Conveying this information to the user is necessary as, updating other fields (other than role) of a developer or a OrgAdmin user would also fail, if he does not provide the ‘”RoleName” : “String”’  field.