2

How can I approve a workflow task using the ListData.svc? I am attempting to just set the value of ApprovalValue to "Approved" but this is not working at all. Any help you can give will probably save my day!

When I set the Approval to:

{"Value": "Approved"}

I get the following error:

"Error processing request stream. Deep updates are not supported in PUT operations."

UPDATE

I have discovered that I can change an item as expected if and only if the item is first approved via the GUI. I have no explanation as to why. If I create an approval item and then approve it using PowerShell

$list = $web.Lists["PAR_Tasks"]
$item = $list.GetItemById(1);

$item["Approval"] = "Rejected";
$item["RejectionReason"] = "Blah"
$item.Update();

and then go back and try to change ANY field using ListData.svc I receive a server 500 error and no information is logged. If I approve it in GUI and then change the value of a field using ListData.svc the item is updated - I can change any field's value I wish.

Any task item that is NOT generated by the WF I can edit just fine by sending a POST with MERGE and

{
    "ApprovalValue":"Approved"
}

as the payload.

I have tested this on 3 different environments and even on the out-of-the-box approval workflow on our department's production site. I get the same results every time. It appears you cannot approve or even change a workflow-generated task item using the ListData.svc Any manually generated item is fine.

Current Conclusion from Testing

My conclusion is that you must use a hybrid approach of ListData.svc with the ECMA CSOM to get the full range of functionality. I won't set this as an answer until it can be confirmed by someone smarter than me, though.

If any of you could take the time to test my theory, please do and I will give you the rep for the answer!

Also confirmed same behavior in SP 2013 using ListData.svc on a CloudShare instance!

7
  • Were you able to resolve this error? Commented Apr 1, 2013 at 23:45
  • 1
    I just wanted to update this and mention we did submit a bug report to Microsoft. It has been confirmed and escalated to the product team. Commented Jul 2, 2013 at 18:32
  • 1
    I have been informed the Sp product team is looking at this issue now. Bug may actually get fixed! Commented Nov 6, 2013 at 21:58
  • 1
    Mike, it's bug that is unlikely to be addressed ever since ListData.svc is deprecated. I did advise MS of the issue. All I can say is that if you have 2013 try to use the new REST API or use JSOM in 2010. If that gets you an error as well, then we are just stuck... Commented Jun 9, 2015 at 17:27
  • 1
    I followed Robert's final conclusion after I got the same error, and switched to JSOM to complete the tasks generated from workflows. This question is the only topic I've researched on the internet that links the 500 error with completing workflow generated tasks using REST.
    – Mike
    Commented Jun 9, 2015 at 19:02

2 Answers 2

0
+50

Update
I can confirm that I receive a server 500 error when attempting to edit a WF generated task with ListData.svc. Some things I haven't looked at yet is comparing that to a task I created and seeing if there are permission differences. Also a 500 error should be generating an error in the log but I can't find anything there either.

Original Proposal:

Try changing the operation to a MERGE operation. See this MSDN article: http://msdn.microsoft.com/en-us/library/ff798339.aspx

beforeSendFunction = function (xhr) 
{
  xhr.setRequestHeader("If-Match", inventoryLocation.__metadata.ETag);
  // Using MERGE so that the entire entity doesn't need to be sent over the wire. 
  xhr.setRequestHeader("X-HTTP-Method", 'MERGE');
}
4
  • Ryan, sorry it took so long. I looked at my code again and I was in fact using 'MERGE'. I am going to do a little more work with this and I will update the question. Currently I have just swapped the update portion of my code out for ECMA CSOM. Commented Apr 11, 2013 at 21:31
  • Ryan, I've added some additional details. Commented Apr 16, 2013 at 19:51
  • updated the answer but I wasn't able to find anything new Commented Apr 17, 2013 at 18:39
  • I am going to move your update to the top so no one mistakenly thinks the MERGE header was the answer. 50 points is worth it for showing that I am not crazy! Has anyone got a 2013 environment they could test the new API service for this? Commented Apr 17, 2013 at 19:12
0

I'm not smart enough to verify this, but you might be able to easily enough: http://aka.ms/cloudlab pointed me to this article:

Step-by-Step: Build a FREE SharePoint 2013 Lab in the Cloud with Windows Azure Infrastructure Services

1
  • I'm sure you are smart enough! I had already spun up a cloud share instance and confirmed it. But thank you for mentioning this as I am constantly forgetting I have access to Azure via my MSDN subscription. Commented Apr 18, 2013 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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