Dynamics 365 Finance & Operations API

104 views Asked by At

I have a MS Dynamics 365 Finance & Operations environment which I'm still configuring. One of the modules is the Timesheet module, for which I need to import from another system. Does MS Dynamics 365 Finance & Operations have an API which I can call specifically for the TimeSheet? or maybe can I use the generic Dynamics API?

I've tried the below code, however I had some issues with the authentications, however I would like to check whether there is an alternative or whether the below code should work

  string baseUri = "https://your-d365-fo-instance-url/ODataV2/TimeSheet";
        string authToken = "Bearer your-auth-token";

        using (var httpClient = new HttpClient())
        {
            httpClient.BaseAddress = new Uri(baseUri);
            httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            httpClient.DefaultRequestHeaders.Authorization = AuthenticationHeaderValue.Parse(authToken);

            // Construct the JSON payload for your timesheet record.
            string timesheetData = "{\"Field1\": \"Value1\", \"Field2\": \"Value2\"}";

            // Send a POST request to insert the record.
            var response = await httpClient.PostAsync("your-entity-name", new StringContent(timesheetData, System.Text.Encoding.UTF8, "application/json"));

Moreover it seems that PowerAutomate also has some in-built premium funciton which allows you to insert into the TimeSheet, maybe someone has already done and can confirm? given that its a premium feature

0

There are 0 answers