msgraph-sdk-php icon indicating copy to clipboard operation
msgraph-sdk-php copied to clipboard

JSON serialization does not encode DateTime of RecurrenceRange correct

Open Dakoni4400 opened this issue 2 years ago • 2 comments

I'm again looking into the JSON serialization of models. I came across a bug in the RecurrenceRange serialization. The API allows the start and end dates to be strings in the format 'Y-m-d', but the model serializes to DateTime::RFC3339 (equal to 'Y-m-d\TH:i:sP'). With this bug the API will not allow any request send with a serialization of a RecurrenceRange in it and you have to fix the request payload manually. I'm willing to fix this bug again in the Code Generator, but I'm not sure if it would be better to fix this directly in the RecurrencePattern Class. Hope you can help me with this.

Code Snippet in Microsoft\Graph\Model\Entity.php referring to this:

if (is_a($val, "\DateTime")) { $serializableProperties[$property] = $val->format(\DateTime::RFC3339); }

Dakoni4400 avatar Nov 12 '21 08:11 Dakoni4400

Thanks for reporting this @Dakoni4400. Looking into this

Ndiritu avatar Nov 12 '21 09:11 Ndiritu

@Dakoni4400 the fix would have to be made in the Code Generator because of other models that require the Date type. I appreciate your willingness to take this on however the team has had some discussion around this and we feel it will be easier if we worked on the bug fix

I'll tag you on the PRs

Ndiritu avatar Nov 17 '21 03:11 Ndiritu

This has been resolved in v2.0 of this SDK. Kindly consider upgrading.

Ndiritu avatar Jan 31 '24 17:01 Ndiritu