Fabian Williams SharePoint Blog

Solving problems with SharePoint day and night

ACTUALLY RESOLVED: Unable to Create List using SharePoint 2013 REST API in SPD2013


Are you ready for this?

Im never satisfied with the answer “No you cant do that”, not as a Developer 🙂 So, i began to read through some TechNet and MSDN articles for Workflow and found this Gem. http://msdn.microsoft.com/en-us/library/jj822159.aspx 

What this Gem does is EXACTLY what Chris Givens found out and did in his PowerShell but as we discussed in my “Resolved post”, we cant run those scripts inside Office 365 SharePoint Online. So, it seems that you have to activate a Site Feature in your Site that you need this “elevated permission” then you need to copy the App Principal ID from the one you want elevated then take that to a “hidden” link inside the App Catalog Site http://{hostname}/{catalog site}/_layouts/15/appinv.aspx and then work your magic to elevate the permissions via an XML node copy / paste magic.

Anyway the GOOD NEWS is that I have tested this in SharePoint Online, and it works like a champ, see below for screenshots.

If you would like the full history of this, see the following post in chronology

  1. https://fabiangwilliams.wordpress.com/2013/09/06/help-unable-to-create-list-using-sharepoint-2013-rest-api-in-spd2013/
  2. https://fabiangwilliams.wordpress.com/2013/09/07/resolved-unable-to-create-list-using-sharepoint-2013-rest-api-in-spd2013/

Proving it out

First me activating the Feature

image

Next grabbing the App Principal ID needed for the Workflow in question. Now i purposely cut off all of the ID, i dont want some crafty person out there using it. Just realize that this is the same account that Chris and I talked about in the PowerShell

image

then moving the piece of Workflow logic that does the List Creation inside the App Step inside SharePoint Designer

image

and finally re-running the Workflow will yield the below in the Workflow History

image

and just to bring it home, here is the new List or (App i guess) Created

image

 

Cheers FGW

Advertisements

September 8, 2013 - Posted by | Azure, JSON, Office 365, SharePoint 2013, SharePoint 2013 Workflows, SharePoint Designer 2013, SharePoint How-To, Strange Stuff

13 Comments »

  1. Fabian, great investigation work. Were you ever successful accessing items in a list located on a different site?

    Comment by ElNa | September 12, 2013 | Reply

  2. Make sure that your App Principal permission has the right scope.

    If you’re creating a list, it can be as granular as /web. If you’re creating a web, it can be as granular as /sitecollection.

    In the msdn article you suggested, the text box has:

    <AppPermissionRequests>
    <AppPermissionRequest Scope=”http://sharepoint/content/sitecollection/web” Right=”FullControl” />
    </AppPermissionRequests>

    But the image below it has:

    <AppPermissionRequests>
    <AppPermissionRequest Scope=”http://sharepoint/content/sitecollection” Right=”FullControl” />
    </AppPermissionRequests>

    See http://msdn.microsoft.com/en-us/library/fp142383.aspx#Perm_types for details. Of course, you will need to have SCA to set the latter.

    Comment by Jim Bob Howard | September 16, 2013 | Reply

  3. Thank you.

    Comment by Morgan Roach | September 18, 2013 | Reply

  4. On SharePoint Online this works through Fiddler or Posting an item to the same site. However, trying to POST between site collections and web applications produces an Access Denied error.

    Thanks for picking this difficult issue apart.

    Comment by Scott | November 20, 2013 | Reply

  5. Never mind. I got it to work. You need to allow workflows to use app permissions on the target site. Then trust the workflow app from the source site. Once I did that I was able to post across site collections.

    Once again, thanks for the article. No way I would have gotten this far without your help!

    Cheers

    Comment by Scott | November 20, 2013 | Reply

    • Scot I am glad you did, I was in Orlando at a Conference and only now seeing this. Cheers

      Comment by fabiangwilliams | November 24, 2013 | Reply

  6. Thanks Fabian, great post.
    Now I can able to create item in another site with Designer Work Flow using Rest API .
    But how to update or delete list item in another site with Rest API ?
    Can you please help on this?

    Comment by Soma Choudhuri | November 27, 2013 | Reply

    • same process see this post here by Kirk Evans as I indicated in my blog he goes over those metods — http://msdn.microsoft.com/en-us/library/jj164022.aspx

      Comment by fabiangwilliams | November 27, 2013 | Reply

      • I can able to update the list items.
        Only thing in the header I have to add
        X-HTTP-Method
        X-RequestDigest
        IF-MATCH…these parameters.
        Thanks Fabian

        Comment by Soma Choudhuri | November 28, 2013

  7. Hi Fabian, Your work is very interesting, but did you ever get the worklow in sharepoint to create a list item?
    I have followed what you have done but I cannot get around the 255 character limit on a string field in SPD 2013 as the header with the Accept, Content-type, content-length and X-RequestDigest elements must add up to more than 255 characters.

    Comment by Simon Kirkby | December 16, 2013 | Reply

    • Actually, I got it to work on many scenarios including List Creation and List Item creation. These are string workflow variables and I haven’t met any limits when creating my headers and Im sure you will see others out there as well with similar experiences. Ensure that you are making separate variables for Accept, Content-Type, Content-Length etc. Its not just one long Header, that is how I am interpreting your comment and if that is what you are doing, it will not work. in all my examples I am building distinct workflow variables for each header.

      Comment by fabiangwilliams | December 16, 2013 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: