2
votes

I am using Microsoft Dynamics 365 Web API approach to interacting with CRM data.

Here I want to update the field with type: DATE and TIME.

Screenshot of field setting

Date value I am passing in the request body is as below:

"packfirstday":"1-15-2018"

Except for above, I have also tried with DateTime and with different date formats. e.g.

mm-dd-yyyy
m-dd-yyyy
mm/dd/yyyy
yyyy/mm/dd
yyyy-mm-dd

PS: I try to post without date field it is saving details successfully.

1
Can you include sample POST request & response ?Ondrej Svejdar
Be careful with your dateformat too. Isn't mm minutes? If you want months I think you need MMjasonscript

1 Answers

3
votes

The problem is not with the code, the simple misunderstanding.

There are 2 components namely Behavior & Format. You have Format set as 'Date only' not the Behavior. Behavior decides the Database terms whereas Format is used for displaying datepicker controls in Form.

enter image description here

So when you set the field in web api with only date part - the CRM database expects time part also.

Either set behavior also as date only, so this will work:

"packfirstday":"2018-01-15" //YYYY-mm-dd format

Or change your code to pass time part also:

"packfirstday":"2018-01-15T11:10:00.000Z" //UTC offset

Since user local behavior still expects the time part.