![]() | |
Users |
This method allows an existing user to be modified. User tab, Structure Access tab and Bank Account Access tab can be modified using this method. In other words, this method mimics the Epic behavior of the following screens:
Can be accessed via the URI [Your_SDK_Service]/api/users/{user_id}.
Request Body
Resource Representation: User Update Request
Response
Status Code: 204
Examples
Updates a user.
1Friend Sub PatchUser() 2 ' Comments For Documentation 3 ' Dim SDK_SERVICE_URI As New Uri("https://Fully_Qualified_Service_Computer_Name/SDK_Service") 4 ' Constant DATABASE preset to current database name 5 ' Constant AUTHENTICATION_KEY set to current authentication key 6 7 'This sample will update the text of a sticky note. 8 Try 9 'This is the unique identifier of a sticky note. 10 'It can be obtained from the response of get users. 11 'Also, from the response of insert logins (Post /api/logins). 12 Dim sUserId As String = "65589" 13 Dim sUsersURL As String = SDK_SERVICE_URI & "/api/users/" & sUserId 14 15 'Adding GroupMembershipItems 16 Dim lstGroupMembershipItems As New List(Of Dictionary(Of String, Object)) 17 Dim dictGroupMembershipItems As New Dictionary(Of String, Object) From { 18 {"flag_code", 0}, 'Action(insert,delete) to be performed on the item. Can be obtained from Get api/lookup_search/user_flags. 19 {"group_membership_id", 65585}} 'Group membership to be added to the user. Can be obtained from Get api/lookup_search/user_group_memberships. 20 lstGroupMembershipItems.Add(dictGroupMembershipItems) 21 22 'Adding StructureAccessItems 23 Dim lstStructures As New List(Of Dictionary(Of String, Object)) 24 Dim dictStructure As New Dictionary(Of String, Object) From { 25 {"flag_code", 0}, 'Action(insert,delete) to be performed on the item. Can be obtained from Get api/lookup_search/user_flags. 26 {"structure_access_id", 65586}} 'Structure combination to be added to the user. Can be obtained from Get api/lookup_search/user_structure_access. 27 lstStructures.Add(dictStructure) 28 29 'Adding BankAccountAccessItems 30 Dim lstBankAccountAccessItems As New List(Of Dictionary(Of String, Object)) 31 Dim lstBankAccounts As New List(Of Dictionary(Of String, Object)) 32 Dim dictBankAccount As New Dictionary(Of String, Object) From { 33 {"flag_code", 0}, 'Action(insert,delete) to be performed on the item. Can be obtained from Get api/lookup_search/user_flags. 34 {"bank_account_id", 65587} 'Bank Account to be added to the user. Can be obtained from Get api/lookup_search/user_bank_accounts. 35 } 36 lstBankAccounts.Add(dictBankAccount) 37 Dim dictBankAccountAccessItem As New Dictionary(Of String, Object) From { 38 {"area_code", "BR"}, ' Bank account access area to be added to the user. Can be obtained from Get api/lookup_search/user_bank_account_access_area. 39 {"bank_accounts", lstBankAccounts}} 40 lstBankAccountAccessItems.Add(dictBankAccountAccessItem) 41 42 Dim dictUpdateRequest As New Dictionary(Of String, Object) From { 43 {"employee_guid", "61875FA1-12DD-459B-A7CD-9F6D34B7A40A"},'employee to be updated. Can be obtained from Get api/lookup_search/user_employees. 44 {"group_membership_items", lstGroupMembershipItems}, 45 {"structure_access_items", lstStructures}, 46 {"bank_account_access_items", lstBankAccountAccessItems} 47 } 48 49 'Notice that other than required properties, only properties that are being changed need to be included in the input request. 50 'Fields that are not included are unmodified. 51 Dim jss As New System.Web.Script.Serialization.JavaScriptSerializer 52 Dim sUserUpdateRequestBody As String = jss.Serialize(dictUpdateRequest) 53 Using oWebclient As New WebClient 54 oWebclient.Encoding = Encoding.UTF8 55 With oWebclient.Headers 56 .Add("AuthenticationKey", AUTHENTICATION_KEY) 57 .Add("DatabaseName", DATABASE) 58 .Add("Content-type", "application/json") 59 End With 60 oWebclient.UploadData(sUsersURL, "PATCH", Encoding.ASCII.GetBytes(sUserUpdateRequestBody)) 61 End Using 62 63 Catch ex As WebException 64 Dim sStatusCode As String = ex.Status.ToString 65 Dim sError As String = New IO.StreamReader(ex.Response.GetResponseStream).ReadToEnd 66 Console.WriteLine("Status Code: " & sStatusCode & ", Error: " & sError) 67 Catch ex As Exception 68 Console.WriteLine(ex.Message) 69 End Try 70 ' Comments For Documentation 71End Sub