User Profile Service
The User Profile service is located at the following URL:
- http(s)://<smarthub-web-app>/Services/UserProfileService.svc
-
- Replace the first part of the URL below with the address of your own SmartHub instance
General Request Details
- type:
GET
andPOST
. - headers:
- You must specify
X-SH-Authorization
in order to authenticate with SmartHub
- You must specify
- contentType: What is being sent to the
server.
application/json;charset=utf-8
is used byGetUserProfileProperties/SetUserProfileProperties
GetUserPicture
uses the default value.
- dataType: What you are expecting back from the server. In our case, this is a JSON response.
- data:
:
GetUserProfileProperties- You can send a total of three parameters:
userName(string)
:- This is the name of the user you want to make the request for.
- If this parameter is missing, it will take identity of the current user.
properties(List<string>)
:- This is the list of properties or property that you want to request.
- By default, the service is going to retrieve all of them: properties from provider + personalized store
personalizedStoreOnly(bool)
:- You can choose to skip the provider and get the values just from the personalized store only (this will decrease the request time).
- By default, this value is set to
false
.
- You can send a total of three parameters:
- SetUserProfileProperties:
- Only one parameter must be specified
properties(Directory<string, string>)
. - Specify a collection of properties and their values.
- Only one parameter must be specified
- GetUserPicture:
- User name is the only parameter required by this method.
- User name is the only parameter required by this method.
- crossDomain:
- Default:
- False for same-domain requests
- True for cross-domain request.
- Default:
Example: Get all user properties
Copy
$.ajax( {
type: "POST",
url: url + "GetUserProfileProperties",
headers: {
'X-SH-Authorization': 'Bearer ' + token
},
contentType: "application/json; charset=utf-8",
dataType: "json",
crossDomain: true
} );
Example: Get a list of user properties
Copy
This request is only going to retrieve the "PropertyName" property, if it exists.
var properties = [ "PropertyName" ];
$.ajax( {
url: url,
type: "POST",
headers: {
'X-SH-Authorization': " Bearer " + token
},
contentType: "application/json; charset=utf-8",
data: JSON.stringify( {
properties: properties
} ),
dataType: "json",
crossDomain: true
} );
Example: Getting just personal properties
Copy
personalizedStoreOnly set to true: Tells the service to skip calling the provider and just grab the data in the personalized store
$.ajax( {
url: url,
type: "POST",
headers: {
'X-SH-Authorization': " Bearer " + token
},
contentType: "application/json; charset=utf-8",
data: JSON.stringify( {
properties: properties,
personalizedStoreOnly: true
} ),
dataType: "json",
crossDomain: true
} );
Example: Get a user picture
Copy
var xhttp = new XMLHttpRequest( );
xhttp.open( "GET", url + "GetUserPicture", true );
xhttp.setRequestHeader( "X-SH-Authorization", "Bearer " + token );
xhttp.responseType = "blob";
xhttp.onreadystatechange = function ( ) {
if ( this.readyState == 4 && this.status == 200 ) {
var blob = new Blob( [ this.response ], {
type: "image/png" } );
window.URL.createObjectURL( blob );
}
}
xhttp.send( );