web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Microsoft Project schedule API Create operation POST body structure

(2) ShareShare
ReportReport
Posted on by 24
Hi,

I am trying to perform CRUD operations on a Microsoft Project project (https://project.microsoft.com/)

I found the Project schedule API, I can fetch all the tasks but cannot create a task. I get this error:

```
{
    "error": {
        "code": "0x80048d19",
        "message": "Error identified in Payload provided by the user for Entity :'',
```

I make a request to this endpoint:  https://MYORGID.api.crm4.dynamics.com/api/data/v9.1/msdyn_PssCreateV1
 
What is the issue with my payload?

```
{
    "Entity": {
        "@odata.type": "Microsoft.Dynamics.CRM.msdyn_projecttask",
        "msdyn_project@odata.bind": "/msdyn_projects(MYPROJECTID)",
        "msdyn_subject": "test",
        "msdyn_scheduledstart": "2024-09-10T00:00:00Z",
        "msdyn_scheduledend": "2024-09-15T00:00:00Z",
        "msdyn_start": "2024-09-10T00:00:00Z",
        "msdyn_projectbucket@odata.bind": "/msdyn_projectbuckets(MPROJECTBUCKETID)",
        "msdyn_LinkStatus": 192350000,
        "msdyn_outlinelevel": 1
    },
    "OperationSetId": "MYOPERATIONSETID"
}
```


These are the functions I'm using to make the requests - in a client-side JavaScript app:

```
import { ensureScope, getToken } from './auth';
 
export async function getProjectTasks() {
    try {
        const accessToken = await getToken();
        ensureScope(`https://${
        import.meta.env.VITE_MICROSOFT_DYNAMICS_ORG_ID
      }.api.crm4.dynamics.com/.default`);
        if (!accessToken) {
            throw new Error('Access token is missing');
        }
 
        const apiUrl = `https://${
        import.meta.env.VITE_MICROSOFT_DYNAMICS_ORG_ID
      }.api.crm4.dynamics.com/api/data/v9.1/msdyn_projecttasks`;
 
        const response = await fetch(apiUrl, {
            method  : 'GET',
            headers : {
                'Authorization'    : `Bearer ${accessToken}`,
                'OData-MaxVersion' : '4.0',
                'OData-Version'    : '4.0',
                'Accept'           : 'application/json',
                'Content-Type'     : 'application/json'
            }
        });
 
        if (!response.ok) {
            throw new Error(`HTTP error! status: ${response.status}`);
        }
 
        const data = await response.json();
        return data;
    }
    catch (error) {
        console.error('Error fetching project entities:', error);
        throw error;
    }
}
 
export async function createOperationSet(projectId, description) {
    const accessToken = await getToken();
    ensureScope(`https://${import.meta.env.VITE_MICROSOFT_DYNAMICS_ORG_ID}.api.crm4.dynamics.com/.default`);
    if (!accessToken) {
        throw new Error('Access token is missing');
    }
 
    const apiUrl = `https://${import.meta.env.VITE_MICROSOFT_DYNAMICS_ORG_ID}.api.crm4.dynamics.com/api/data/v9.1/msdyn_CreateOperationSetV1`;
 
    const payload = {
        'ProjectId'   : projectId,
        'Description' : description
    };
 
    const response = await fetch(apiUrl, {
        method  : 'POST',
        headers : {
            'Authorization'    : `Bearer ${accessToken}`,
            'OData-MaxVersion' : '4.0',
            'OData-Version'    : '4.0',
            'Accept'           : 'application/json',
            'Content-Type'     : 'application/json'
        },
        body : JSON.stringify(payload)
    });
 
    if (!response.ok) {
        throw new Error(`HTTP error! status: ${response.status}`);
    }
 
    const data = await response.json();
    return data.OperationSetId;
}
 
export async function createProjectTask(projectId, projectBucketId, operationSetId) {
    const accessToken = await getToken();
    ensureScope(`https://${import.meta.env.VITE_MICROSOFT_DYNAMICS_ORG_ID}.api.crm4.dynamics.com/.default`);
    if (!accessToken) {
        throw new Error('Access token is missing');
    }
 
    const apiUrl = `https://${import.meta.env.VITE_MICROSOFT_DYNAMICS_ORG_ID}.api.crm4.dynamics.com/api/data/v9.1/msdyn_PssCreateV1`;
 
    const payload = {
        'Entity' : {
            '@odata.type'                    : 'Microsoft.Dynamics.CRM.msdyn_projecttask',
            'msdyn_project@odata.bind'       : `/msdyn_projects(${projectId})`,
            'msdyn_subject'                  : 'test',
            // "msdyn_effort": '',
            'msdyn_scheduledstart'           : '2024-09-10T00:00:00Z',
            'msdyn_scheduledend'             : '2024-09-15T00:00:00Z',
            'msdyn_start'                    : '2024-09-10T00:00:00Z',
            'msdyn_projectbucket@odata.bind' : `/msdyn_projectbuckets(${projectBucketId})`,
            'msdyn_LinkStatus'               : 192350000,
            'msdyn_outlinelevel'             : 1
            // '@odata.type'                    : 'Microsoft.Dynamics.CRM.msdyn_projecttask',
            // 'msdyn_LinkStatus'               : 192350000,
            // 'msdyn_subject'                  : 'test',
            // 'msdyn_start'                    : '2024-09-10T00:00:00Z', // Example start date
            // 'msdyn_finish'                   : '2024-09-15T00:00:00Z', // Example finish date
            // 'msdyn_project@odata.bind'       : `/msdyn_projects(${projectId})`,
            // 'msdyn_projectbucket@odata.bind' : `/msdyn_projectbuckets(${projectBucketId})`
        },
        'OperationSetId' : operationSetId
    };
 
    const response = await fetch(apiUrl, {
        method  : 'POST',
        headers : {
            'Authorization'    : `Bearer ${accessToken}`,
            'OData-MaxVersion' : '4.0',
            'OData-Version'    : '4.0',
            'Accept'           : 'application/json',
            'Content-Type'     : 'application/json'
        },
        body : JSON.stringify(payload)
    });
 
    if (!response.ok) {
        throw new Error(`HTTP error! status: ${response.status}`);
    }
 
    const data = await response.json();
    return data;
}
```

 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 555 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 484 Super User 2026 Season 2

#3
CU10121822-0 Profile Picture

CU10121822-0 378

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans