![]() | |
UsersSearch |
This method is used to retrieve users. In other words, this method mimics the Epic behavior of the following screens:
Can be accessed via the URI [Your_SDK_Service]/api/user_search?fields={properties}.
Request Parameters
fields
Type: System.String
Specify the properties that the partial response will contain. Accepted values can be string separated by comma. If not present, the response will contain all properties.
Request Body
Resource Representation: UserFilter
Response
Status Code: 200
Type: List(Of User)
A list of Users that match the input information.
Examples
Get users.
1Friend Sub GetUsers() 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 retrieve the User info for the specified user Code. 8 'The response will only have parameters listed in the query: fields=user_code,full_name,user_type,user_status. 9 'If the query is omitted the method returns full response. 10 Try 11 Dim sUserUrl As String = SDK_SERVICE_URI & "/api/user_search?fields=user_code,full_name,user_type,user_status" 12 13 Dim dictGetRequest As New Dictionary(Of String, String) From { 14 {"user_code", "ENTERPRISEADMIN"} 'User codes can be obtained from Post /api/user_search without filter. 15 } 16 17 Dim jss As New System.Web.Script.Serialization.JavaScriptSerializer 18 Dim sUserGetRequestBody As String = jss.Serialize(dictGetRequest) 19 20 Dim sResponse As String 21 Using oWebclient As New WebClient 22 oWebclient.Encoding = Encoding.UTF8 23 With oWebclient.Headers 24 .Add("AuthenticationKey", AUTHENTICATION_KEY) 25 .Add("DatabaseName", DATABASE) 26 .Add("Content-type", "application/json") 27 End With 28 Dim aResponse As Byte() = oWebclient.UploadData(sUserUrl, "POST", Encoding.ASCII.GetBytes(sUserGetRequestBody)) 29 sResponse = oWebclient.Encoding.GetString(aResponse) 30 End Using 31 Dim lstUser As List(Of Dictionary(Of String, String)) = jss.Deserialize(Of List(Of Dictionary(Of String, String)))(sResponse) 32 For Each dictUser As Dictionary(Of String, String) In lstUser 33 Console.WriteLine("User Code: " & dictUser("user_code")) 34 Console.WriteLine("Full Name: " & dictUser("full_name")) 35 Console.WriteLine("User Type: " & dictUser("user_type")) 36 Console.WriteLine("User Status: " & dictUser("user_status")) 37 Console.WriteLine() 38 Next 39 40 Catch ex As WebException 41 Dim sStatusCode As String = ex.Status.ToString 42 Dim sError As String = New IO.StreamReader(ex.Response.GetResponseStream).ReadToEnd 43 Console.WriteLine("Status Code: " & sStatusCode & ", Error: " & sError) 44 Catch ex As Exception 45 Console.WriteLine(ex.Message) 46 End Try 47 48 'Comments For Documentation 49End Sub