mercredi 28 janvier 2015

How to create list item in an external list using SharePoint workflow?

Environment: SharePoint 2013 SP1


I have an External List displaying data exposed through a WCF service. Creating, Reading, Updating and Deleting (CRUD) items in the external list works fine in the browser.


I need to be able to perform CRUD operations on the external list from a SharePoint workflow attached to a normal SharePoint list, regardless if it is:



  • a SPD 2010 workflow,

  • a SPD 2013 workflow,

  • a VS workflow,

  • using REST API or not.


Any solution is good!




What I have tried so far is:



  1. SPD 2010 workflow on normal SharePoint list with Create List Item action on one of the External Lists I have. The problem is that after selecting an external list, I cannot set any field of that external list because it does not display any.


  2. SPD 2013 workflow on normal list with Call HTTP web service action using the external list's REST API. I can get the FormDigestValue just fine via "[site url]/_api/contextinfo" to set the X-RequestDigest header of a second Call HTTP web service action that is supposed to create an item in the external list:



    • X-RequestDigest header is set to 0x..., namely the form digest value

    • Accept header is set to application/json;odata=verbose

    • Content-Type header is set to application/json;odata=verbose


    I am using an App Steps for each Call HTTP web service action, where the App Step runs with FullControl on the web where the normal list and the external lists are.


    I provide the correct metadata and list item type, plus the external list fields that need to be set for a new item. The ResponseCode of the second Call HTTP web service action is Created, so it tells me that the item is created, but in reality it is not. The ResponseBody contains only null values for the fields.


    The same happens if I use Postman or Fiddler to make a POST request to http://sharepoint/sites/dev/_api/lists/getbytitle('My_External_List')/items using the same headers from above and some input data.


    The STATUS code I get is 201 Created. The JSON response I get from this POST request shows "BdcIdentity": null instead of some 0x... value, and d/__metadata/uri contains /GetItemByStringId(null) instead of /GetItemByStringId( value of BdcIdentity ).


    I do not understand what goes wrong, especially because POST requests with the "X-HTTP-Method":"DELETE" work just fine, so it does not look like an authentication or authorization problem.



    1. I still have not tried using a Visual Studio workflow with the HttpSend method.




Does anyone have any idea why I have problem with creating an external list item via REST API? Or does anyone know a sure-fire solution to write to an external list from a workflow in SP 2013?


Aucun commentaire:

Enregistrer un commentaire