Forum Discussion

rei03002's avatar
rei03002
Copper Contributor
Mar 12, 2025

Issues with Creating and Linking Related Entities When Creating an Entity in Project Online

Good day all!

I am currently working with Project Online, where I am trying to create entities and utilizing OData’s “Create Related Entities When Creating an Entity” feature. For more details, please refer to the OData documentation linked below: https://www.odata.org/documentation/odata-version-3-0/odata-version-3-0-core-protocol/#datamodification:~:text=10.3.2.2.%20Create%20Related%20Entities%20When%20Creating%20an%20Entity

In the OData metadata, there is an entity type named DraftTask, which includes a navigation property called Assignments. When creating a new DraftTask entity, I am also attempting to create an Assignment entity by including an Assignments object in the POST request body and specifying its properties. Please see the request below:

POST https://{site}.sharepoint.com/sites/pwa/_api/ProjectServer/Projects(guid'{project_id}')/Draft/Tasks

{
               "Name": "My Test Draft Task",
               "ActualCost": "42",
               "Assignments": [
                              {
                                             "Notes": "TestNote"
                              }
               ]
}

I receive an “HTTP/1.1 201 Created” response along with a representation of the newly created DraftTask object. However, I do not see any relation between the created DraftTask and the Assignment entity (with the specified Notes).

Even when I perform a GET request to retrieve the currently created draft task using the returned Id and expand the Assignments property, the relation is still missing. It appears that the server only creates the base DraftTask entity without creating the associated Assignment. However, according to the OData documentation, the service must create and relate each entity upon success.

Does anyone know if Project Online Server supports this type of entity creation according to the OData standard?

Additionally, the OData documentation supports another method of entity creation that establishes an association with an existing related entity, known as 'Link to related entities when creating an entity.' According to the OData documentation: https://www.odata.org/documentation/odata-version-3-0/odata-version-3-0-core-protocol/#datamodification:~:text=10.3.2.1.%20Link%20to%20Related%20Entities%20When%20Creating%20an%20Entity 

I am attempting this approach using the @odata.bind annotation. Please see the request below.

POST https://{site}.sharepoint.com/sites/pwa/_api/ProjectServer/Projects(guid'{project_id}')/Draft/Tasks

{
               "Name": "My Test Draft Task 2",
               "ActualCost": "21",
               "email address removed for privacy reasons": [
             
"https://{site}.sharepoint.com/sites/pwa/_api/ProjectServer/Projects(guid'{project_id}')/Draft/Assignments(guid'{existing_assignment_id}')"
               ]
}

The behavior remains the same - the server successfully creates the DraftTask object but does not establish an association with the referenced Assignment entity.

Does Project Online support this type of entity creation, or does it only allow creating the base entity?

I would appreciate any insights on this. Looking forward to your response!

Best regards!

No RepliesBe the first to reply

Resources