vrvoice1 | 2016-08-01 11:30:53 UTC | #1
Hi,
I want to set the property OutOfOffice for a user. For that I'm using the following code:
ININ.PureCloudApi.Model.OutOfOffice ooo = new ININ.PureCloudApi.Model.OutOfOffice(); ooo.Active = true; ooo.StartDate = DateTime.Now; ooo.EndDate = DateTime.Now.AddMonths(1);
var oo = userApi.PutUserIdOutofoffice(users.Entities.Single(e => e.Name.StartsWith("Sven")).Id, ooo);
I get this exception:
Error calling PutUserIdOutofoffice: {"status":400,"code":"invalid.date","message":"Dates must be specified as ISO-8601 strings. For example: yyyy-MM-ddTHH:mm:ss.SSSZ"}
I think there is a problem with the serialisation in the Api?
But I have another question for this Api request. What can I do with the Name and User property in OutOfOffice Model? In my Postman try I need only the Active, Start and EndDate property to set it to activ.
Perhaps is there a opportunity to forward the incoming call to a Queue and not to voicemail?
Regards,
Sven
tim.smith | 2016-08-01 14:58:09 UTC | #2
Can you provide a context ID from the response you get when date deserialization fails? It's more likely that there's an issue with how the SDK is sending the date, but I can look at the logs if I can get a context ID from the response.
What can I do with the Name and User property in OutOfOffice Model? In my Postman try I need only the Active, Start and EndDate property to set it to activ.
The only properties you need are active, startDate, and endDate. The resource reuses the response object as the request object, so it documents all of the properties even though most are ignored if used in the request.
vrvoice1 | 2016-08-03 06:32:03 UTC | #3
Hi Tim,
this is the context ID 4ea0f5d2-05e7-4639-ada4-3794bfe93cae
The request JSON is the following: { "startDate": "2016-08-03T08:24:21.5989785+02:00", "endDate": "2016-09-03T08:24:21.5989785+02:00", "active": true }
tim.smith | 2016-08-03 15:18:47 UTC | #4
The SDK is indeed the issue. I've created API-1804 to track this and am working on it now. Should have a new version out today.
tim.smith | 2016-08-03 16:02:39 UTC | #5
I've published SDK version 0.67.0.323 with a fix for this. Let me know if you have any further issues. My test code used to verify:
var usersApi = new UsersApi(); var ooo = new OutOfOffice(Active: true, StartDate: DateTime.Now, EndDate: DateTime.Now.AddMonths(1)); var response = usersApi.PutUserIdOutofoffice(_me.Id, ooo);
vrvoice1 | 2016-08-04 08:05:39 UTC | #6
Hi Tim, thanks for the fast answer, but for me, it doesn't work. The issue is the same.
My test code:
namespace SetOutOfOffice { class Program { [STAThread] static void Main(string[] args) {
var form = new OAuthWebBrowserForm(); form.oAuthWebBrowser1.ClientId = "xxx"; form.oAuthWebBrowser1.ClientSecret = "xxx"; form.oAuthWebBrowser1.RedirectUriIsFake = true; form.oAuthWebBrowser1.RedirectUri = "http://localhost/"; form.oAuthWebBrowser1.Environment = "mypurecloud.ie";
var result = form.ShowDialog();
if (result == DialogResult.OK) {
Configuration.Default.ApiClient = new ApiClient("https://api.mypurecloud.ie"); Configuration.Default.AccessToken = form.oAuthWebBrowser1.AccessToken;
} else { throw new Exception("Failed to authorize!"); }
var usersApi = new UsersApi();
var me = usersApi.GetMe();
var ooo = new OutOfOffice(Active: true, StartDate: DateTime.Now, EndDate: DateTime.Now.AddMonths(1)); var s = ooo.ToJson();
var response = usersApi.PutUserIdOutofoffice(me.Id, ooo);
} } }
<img src="//inin-prod-use1-developerforum.s3.amazonaws.com/original/1X/b5e171766ca0a668c1fc0a5df098883d62cb57b9.PNG" width="690" height="237">
The version is the newest I can get: <img src="//inin-prod-use1-developerforum.s3.amazonaws.com/original/1X/9df23f2066d1fc0a5f093498835f11c08b8ca65e.PNG" width="346" height="80">
Could it be a problem with the environment EMEA or the culture (de-DE)? Perhaps it is helpful for you, the var s =
{ "startDate": "2016-08-04T10:01:12.3669565+02:00", "endDate": "2016-09-04T10:01:12.3669565+02:00", "active": true }
tim.smith | 2016-08-04 13:17:07 UTC | #7
Hm, look in your package.config to verify that the SDK version was updated.
What string do you get from this code run on your machine?
var dateString = DateTime.Now.ToUniversalTime().ToString("s", CultureInfo.InvariantCulture);
vrvoice1 | 2016-08-04 13:33:15 UTC | #8
Tim,
the SDK is the right one: <package id="PureCloudApiSdk" version="0.67.0.323" targetFramework="net461" />
The dataString is:
2016-08-04T13:29:31
Regards,
Sven
tim.smith | 2016-08-04 13:41:07 UTC | #9
Interesting. The code I sent is what the new version of the SDK is doing, so the correct value you pasted is what the SDK should be sending. Can you get a context ID from the response so I can look at the logs for the request?
vrvoice1 | 2016-08-04 13:51:07 UTC | #10
{ININ-Correlation-Id=bea58666-fed4-42ab-8cbb-394f94f3e27e}
tim.smith | 2016-08-04 14:01:39 UTC | #11
Thanks. That confirmed that you are using the correct version of the SDK (it's in the user agent header on all requests) and that the date isn't being sent correctly. I'm going to try implementing the serializer in a different way. Would you be able to test a one-off build if I provide it to you? I'm unable to reproduce this issue locally.
A note on the line ooo.ToJson(): That method doesn't use the same serializer that's used by the ApiClient class that makes the request. The ApiClient class has its own serializer that has a few customizations in it, including the custom DateTime serializer that I added. So the serialized body you get from the ToJson() method isn't necessarily the same as what gets sent by the request. Though in this case it unfortunately is the same because the serializer isn't working correctly.
vrvoice1 | 2016-08-04 14:08:52 UTC | #12
Hi Tim,
I think there is a problem with the serializerSettings. In the method public ApiClient() { Configuration = Configuration.Default; RestClient = new RestClient("https://api.mypurecloud.com"); serializerSettings.Converters.Add(new Iso8601DateTimeConverter()); }
you set the right converter. But the Iso8601DateTimeConverter is never used if I make a breakpoint in there. And in the Serialize method the converter list is empty <img src="//inin-prod-use1-developerforum.s3.amazonaws.com/original/1X/b0b2ac0b07e531b160488e1e195c8416fc1250a2.PNG" width="690" height="325">
For sure I can test it for you.
tim.smith | 2016-08-04 14:11:53 UTC | #13
That gives me something to go on, appreciate it!
vrvoice1 | 2016-08-04 14:22:12 UTC | #14
I think the ApiClient constructor is the problem. I'am using this one: ` public ApiClient(String basePath = "https://api.mypurecloud.com")`
I add there the line <img src="//inin-prod-use1-developerforum.s3.amazonaws.com/original/1X/d5eaf6795d8a265ca0fdce6bdf8ab42b38352846.PNG" width="573" height="200">
Thats working :slight_smile:
tim.smith | 2016-08-04 14:26:23 UTC | #15
OH! I completely glossed over the fact that there are multiple constructors for the ApiClient. Will fix that and publish a new version momentarily.
tim.smith | 2016-08-04 15:01:57 UTC | #17
The new version 0.69.0.327 has been published on nuget. Give that a try and let me know if that resolves your issue. I've added the serializerSettings line to all of the constructors.
vrvoice1 | 2016-08-05 06:17:30 UTC | #18
Tim,
it's working. Very nice, thanks.
Regards,
Sven
system | 2017-08-28 19:25:43 UTC | #19
This post was migrated from the old Developer Forum.
ref: 194