Ask the Community
Groups
Getting a "Nullable object must have a value" When Disabling a User via the API - Connect IT Community | Kaseya
<main> <article class="userContent"> <h3 data-id="problem">Problem</h3> <p>When using the VSA REST API to disable a user as explained in our <a rel="nofollow" href="/home/leaving?allowTrusted=1&target=http%3A%2F%2Fhelp.kaseya.com%2Fwebhelp%2FEN%2FRESTAPI%2F9050000%2F%2331750.htm">help section</a>. You get the following error message:</p> <p>{'ResponseCode': 500, 'Status': 'Failed', 'Error': 'Nullable object must have a value.'}</p> <h3 data-id="cause">Cause</h3> <p>There is an attribute missing from the user's record, the "DisableUntil" from the JSON response.</p> <pre class="code codeBlock" spellcheck="false" tabindex="0"> {<br> "UserId": 87589180,<br> "AdminName": "329735",<br> "AdminPassword": "coverde9695f4a51d64a72b29a9c34b1c129b58dd8091470bfa5edd3d74e1bd9aaef4",<br> "Admintype": 2,<br><strong> "DisableUntil": null,</strong><br> "CreationDate": "2018-12-12T15:17:25.733",<br> "AdminScopeIds": [<br> "21168248811635593222129149",<br> "2"<br> ],<br> "AdminRoleIds": [<br> 2,<br> 481786817<br> ],<br> "FirstName": "Kaseya",<br> "LastName": "Test",<br> "DefaultStaffOrgId": "87197147124176153217817313",<br> "DefaultStaffDepartmentId": "41282171841258424815687848",<br> "Email": "noreply@kaseya.com",<br> "UIMode": "0",<br> "Attributes": <strong>null</strong><br> }</pre> <h3 data-id="resolution-or-workaround">Resolution or Workaround</h3> <ul><li>We need to grab the user details, by using the <a rel="nofollow" href="/home/leaving?allowTrusted=1&target=http%3A%2F%2Fhelp.kaseya.com%2Fwebhelp%2FEN%2FRESTAPI%2F9050000%2F%2331738.htm">Get User</a> API endpoint.</li> <li>Grab the json body, and modify the DisableUntil or replace the null with <strong>"1980-01-01T00:00:00" [Update the Disable Until to something like "1980-01-01T00:00:00"]</strong> </li> <li>Then we can update the user to ensure the DisableUntil has a valid date. </li> <li>Use the <a rel="nofollow" href="/home/leaving?allowTrusted=1&target=http%3A%2F%2Fhelp.kaseya.com%2Fwebhelp%2FEN%2FRESTAPI%2F9050000%2F%2331749.htm">Update User</a> REST API endpoint.</li> </ul><pre class="code codeBlock" spellcheck="false" tabindex="0"> {<br> "UserId": 87589180,<br> "AdminName": "329735",<br> "AdminPassword": "coverde9695f4a51d64a72b29a9c34b1c129b58dd8091470bfa5edd3d74e1bd9aaef4",<br> "Admintype": 2,<br><strong> "DisableUntil": "1980-01-01T00:00:00",</strong><br> "CreationDate": "2018-12-12T15:17:25.733",<br> "AdminScopeIds": [<br> "21168248811635593222129149",<br> "2"<br> ],<br> "AdminRoleIds": [<br> 2,<br> 481786817<br> ],<br> "FirstName": "Kaseya",<br> "LastName": "Test",<br> "DefaultStaffOrgId": "87197147124176153217817313",<br> "DefaultStaffDepartmentId": "41282171841258424815687848",<br> "Email": "noreply@kaseya.com",<br> "UIMode": "0",<br> "Attributes": <strong>null</strong><br> } </pre> <p>Make sure to send the entire details as a body in the API call.</p> <p><strong>NOTE</strong>: The user used for the API call must have a matching Role and Scope ID to the user that you are modifying. </p> </article> </main>