1

I've figured out how to update a Task's basic fields via the OData Rest service using POST (X-HTTP-Method=MERGE):

/ProjectServer/Projects('{#project}')/Draft/Tasks('{#Id}')

The post content is a JSON object with each standard field's internal name mapped to a value.

But how do I update custom fields? Attempts to write to their internal name in MSPS 2016 are ignored.

How to write custom fields on projects can be found here. But I'm having trouble finding similar REST API for Task custom fields.

0

This is possible but as far as I can see not documented anywhere by Microsoft. Through some Fiddler tracing of the JSOM API I figured out the following way to do this using the ProcessQuery internal SharePoint endpoint. (That's the one that CSOM/JSOM use internally)

    POST /sites/pwa/_vti_bin/client.svc/ProcessQuery HTTP/1.1
    Host: something.sharepoint.com
    Accept: application/json; odata=verbose
    Content-Type: text/xml
    X-RequestDigest: ......
    Cache-Control: no-cache

    <?xml version="1.0" ?>
    <Request ApplicationName="Javascript Library" LibraryVersion="15.0.0.0" SchemaVersion="15.0.0.0" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009">
    <Actions>
        <ObjectPath Id="1" ObjectPathId="0"/>
        <ObjectPath Id="3" ObjectPathId="2"/>
        <ObjectPath Id="5" ObjectPathId="4"/>
        <ObjectPath Id="7" ObjectPathId="6"/>
        <ObjectPath Id="9" ObjectPathId="8"/>
        <ObjectPath Id="11" ObjectPathId="10"/>
        <ObjectPath Id="13" ObjectPathId="12"/>
        <Method Id="14" Name="SetCustomFieldValue" ObjectPathId="12">
            <Parameters>
                <Parameter Type="String">Custom_976b57c4b836e51180cd000d3a201c32</Parameter>
                <Parameter Type="String">Hi</Parameter>
            </Parameters>
        </Method>
        <ObjectPath Id="16" ObjectPathId="15"/>
        <Query Id="17" ObjectPathId="15">
            <Query SelectAllProperties="true">
                <Properties/>
            </Query>
        </Query>
    </Actions>
    <ObjectPaths>
        <Constructor Id="0" TypeId="{3a609e5f-e2a1-497c-87a2-e5e8a781c096}"/>
        <Constructor Id="2" TypeId="{f256f605-bb33-4d62-b206-72a06a765075}">
            <Parameters>
                <Parameter ObjectPathId="0"/>
            </Parameters>
        </Constructor>
        <Property Id="4" Name="Projects" ParentId="0"/>
        <Method Id="6" Name="GetByGuid" ParentId="4">
            <Parameters>
                <Parameter Type="String">36ead592-ee70-e611-8162-000d3a2402b4</Parameter>
            </Parameters>
        </Method>
        <Property Id="8" Name="Draft" ParentId="6"/>
        <Property Id="10" Name="Tasks" ParentId="8"/>
        <Method Id="12" Name="GetByGuid" ParentId="10">
            <Parameters>
                <Parameter Type="String">150aca09-ef70-e611-8162-000d3a2402b4</Parameter>
            </Parameters>
        </Method>
        <Method Id="15" Name="Update" ParentId="8"/>
    </ObjectPaths>
</Request>

The above example updates a task custom field after checking out the project, it was specifically 'discovered' using the 2013 JSOM object model, but from recent experience the syntax has simplified in the current version.

If you want to see read how I found this, and how to determine the syntax for other undocumented endpoints, I blogged about this here: nearbaseline.com

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.