vrvoice1 | 2016-07-05 10:23:57 UTC | #1
Hi, I have tried to set a userpresence about the Platform API. The example is working fine but now I can't set the userpresence about the mypurecloud Website to an other presence.
For example: If I set it to Break on the Website, it seems that the change is done but if I go to an other page like Directory or something else it goes back to "Available"(I have set "Available" with my program).
<code csharp > static void Main(string[] args) { Configuration.Default.ApiClient = new ApiClient("https://api.mypurecloud.ie"); var accessTokenInfo = Configuration.Default.ApiClient.PostToken("xxx", "xxx"); Console.WriteLine("Access-Token" + accessTokenInfo.AccessToken); Configuration.Default.AccessToken = accessTokenInfo.AccessToken;
UsersApi userApi = new UsersApi(); PresenceApi presensceApi = new PresenceApi();
var presenceDefs = presensceApi.GetPresencedefinitions();
OrganizationPresence pd = null;
foreach (var item in presenceDefs.Entities) { if (item.LanguageLabels.First().Value.StartsWith("Available")) { pd = item; break; } }
var users = userApi.GetUsers();
var sven = users.Entities.SingleOrDefault(u => u.Name.EndsWith("xxxxx"));
var h = presensceApi.PatchUserIdPresencesSourceId(sven.Id, pd.Id, new ININ.PureCloudApi.Model.UserPresence() { Primary = true });
} </code>
How do I get the presence via the website to run again?
Kind regards,
Sven
KevinGlinski | 2016-07-08 15:33:58 UTC | #2
the second parameter in your Patch method is incorrect. Here is a code sample in JS
function setPresence(presenceId){ console.log("Setting presence to " + presenceId); // Create request body var newPresence = { "presenceDefinition" : { "id": presenceId } };
// Patch presence presenceApi.patchUserIdPresencesSourceId(userId, 'PURECLOUD', newPresence); }
So i think if you changed your code to
var h = presensceApi.PatchUserIdPresencesSourceId(sven.Id, "PURECLOUD", pd);
it might work
vrvoice1 | 2016-07-11 06:29:06 UTC | #3
Hi Kevin, thanks now it works. But why I need a parameter if it's a constant?
Regards,
Sven
KevinGlinski | 2016-07-11 13:16:38 UTC | #4
The interface is built to support future presence providers e.g. a Skype for Business presence that is merged with Purecloud
system | 2017-08-28 19:25:09 UTC | #5
This post was migrated from the old Developer Forum.
ref: 115