none
Unable to update custom field of a Project in Project Online using REST RRS feed

  • Question

  • Hi i want to update one custom field of a Project in Project Online using REST. Here is the code

    ***************************************************

    body="{'customFieldDictionary':[{'__metadata': { 'type': 'SP.KeyValue' },'Key':'Custom_4f211fb5b754e611810900155d40aa00','Value':'ABC', 'ValueType':'Edm.String'}]}";
    $.ajax({

            url: "<site>/_api/ProjectServer/Projects('guid')/Draft/UpdateCustomFields",
            method: "POST",
            headers: { "Accept": "application/json; odata=verbose",
    "X-RequestDigest" : $("#__REQUESTDIGEST").val(),
    },
    data: JSON.stringify(body),
            success: function(data){
    debugger;             
                 });             
            },
            error: function(error){
    debugger;
                alert(JSON.stringify(error));
            }
    });

    ***************************************************Every time i get following error{"error":{"code":"-1, System.InvalidOperationException","message":{"lang":"en-US","value":"The type of data at position 0 is different than the one expected."}}}. I think there is some wrong JSON getting passed in body variable. I have referred https://msdn.microsoft.com/en-us/library/office/mt143443.aspx and https://github.com/OfficeDev/Project-REST-Basic-Operations/blob/master/updateprojectcustomfieldvalues.ps1 but no luck. Kindly help. 

    Sunday, August 21, 2016 6:33 AM