It is possible to create portal users via API or WebAPI, using a similar mechanism to what is described above.
Usage via API
In the API you will need to use the 'ThePortalUserSync' class. It has similar properties as the 'TheUserSync' DB table mentioned in the section above.
This sample displays how to add one portal search for one user:
// adding one portal search for one user
ThePortalUserSync userSync = new ThePortalUserSync();
userSync.Email = "apiPortal@therefore.net";
userSync.QueryNo = 363;
userSync.UserName = "apiPortal@therefore.net";
userSync.UserPwd = string.Empty; // generates a password for the user
// add conditions
TheCondition condition = new TheCondition();
condition.FieldNo = 123;
condition.Condition = "some condition";
userSync.Conditions.Add(condition);
userSync.SavePortalUser(server);d
To add multiple searches for one user you will need to specify the same Email/Username and specify a different QueryNo.
The following sample can be used to add one upload for a portal user.
//adding one portal upload for one user
ThePortalUserSync userSyncUpload = new ThePortalUserSync();
userSyncUpload.Email = "apiPortal@therefore.net";
userSyncUpload.CtgryNo = 68;
userSyncUpload.UserName = "apiPortal@therefore.net";
userSyncUpload.UserPwd = string.Empty;
//set pre-defined values for index data fields, for this portal user
userSyncUpload.IndexData.SetCategory(68, server);
userSyncUpload.IndexData.SetValueByFieldID("Text", "some predefined value");
userSyncUpload.SavePortalUser(server);
Usage via WebAPI
The WebAPI call will work the same way. Additional documentation for this can be found in our WebAPI documentation:
SavePortalUser (therefore.net)
Sample call for adding portal search to a user:
{
"PortalUser": {
"Conditions": [
{
"FieldNoOrName" : "1019",
"Condition" : "1"
}
],
"Email": "myEmail@test.com",
"IndexDataItems":[],
"QueryNo": "163",
"UserName": "test6",
"UserPwd": "Abcd1234"
}
}
|
Please note neither API or WebAPI portal user creation is instant. It will take up to 10 minutes until the portal user has been created.
|
|