function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Er. Puneet GoelEr. Puneet Goel 

Create Event using Enterprise API throw error REQUIRED_FIELD_MISSING for DurationInMInutes and ActivityDateTime

Hi i am succesfully logged in Salesforce account and able to add account and contacts. Now i am trying to add new event to logged in user's account. Below is the code of how i am doing this.

                        enterpriseAPI.Event n_Event = new enterpriseAPI.Event();
                        n_Event.Subject = "Test Integration with salesforce event";

                        n_Event.StartDateTime = DateTime.Now.AddMinutes(10);
                        n_Event.EndDateTime = DateTime.Now.AddMinutes(40);
                        n_Event.IsAllDayEvent = true;
                        n_Event.Description = "I have created this event from VS Project to test the integration.";
                        n_Event.DurationInMinutes = 30;
                        //n_Event.ActivityDate = DateTime.Now.Date;
                        n_Event.ActivityDateTime = DateTime.Now.AddMinutes(50);

                        //execute Query
                        queryClient.create(header, null, null, null, null, null, null, null, null, null, new enterpriseAPI.sObject[] { n_Event }, out out_limitInfo, out out_result);

I have supplied all the required fields, but it still throwing REQUIRED_FIELD_MISSING error for DurationInMInutes and ActivityDateTime.

Please help me out to fix this issue.
Vinit_KumarVinit_Kumar
As per the salesforce doc for ActivityDateTime field it says below,

'The value for this field and StartDateTime must match, or one of them must be null.'

I see your StartDateTime and ActivityDateTime are different.

Can you try sernding the request by setting same time for both fields.

If this helps,please mark it as best answer to help others :)
Er. Puneet GoelEr. Puneet Goel
@Vinit_Kumar

I also tried as per mentioned by you 

I tried : 1. By setting Both the time same and
           : 2. By setting one of them null

But in both the cases, it throws the same error. :(

let me knwo if you have some other soultion.