PowerShell has a great built-in commandlet to call REST methods called Invoke-RestMethod. However, it might take some tinkering to get it working against the SharePoint RESP API. Here is a sample script that will first get the form digest and then pass it in the header of subsequent requests. As an example, this script will create a folder in the specified document library-

Note that this script only calls the POST method during the folder creation example. A GET method is also specified in this script which will come in handy for other types of operations where information is being read from SharePoint. Depending on the task, a MERGE or DELETE method may also be required and can be declared exactly the same way as the GET/POST methods.

For further reference, here is the SharePoint REST API documentation: http://msdn.microsoft.com/en-us/library/office/jj860569(v=office.15).aspx


19 Responses to Use PowerShell’s Invoke-RestMethod with the SharePoint 2013 REST API

  1. Greg Tate says:

    This was lifesaver…The example was a great help in getting me down the right path on using REST to upload a file. Thanks!

  2. leigh says:

    Great script.

    But please use write-debug rather than write-hos with the checkt, and please note that Jeffrey Snover says anytime you use write-host, a kitten dies.

  3. Anonymous says:

    Great job!!! I try to add a finction to update list item but it’s too difficult for me now…If someone has an idea?

  4. Christoph Mülder says:

    Thanks a lot for this. Needed some time to get it right but then I have been able to achieve what I wanted with the help of your functions.

  5. BestCarin says:

    I have noticed you don’t monetize your page, don’t waste your traffic, you can earn extra cash every month.
    You can use the best adsense alternative for any type of
    website (they approve all websites), for more details simply search in gooogle:
    boorfe’s tips monetize your website

  6. mike says:

    Do you have an example that uses PostRequest for placing a file into SharePoint?

  7. Anonymous says:

    Very nice.Thanks!.

  8. Rohit says:

    Thanks Pranav for this nice article on SharePoint 2013.

    I want to make a post call on SharePoint Online and the Multi-Factor Authentication is enabled. I am not able to figure out how do I connect to sharepoint using “Invoke-RestMethod” method.

    Could you please suggest me.

  9. Nell Pridham says:

    Good day!

    You Need Leads, Sales, Conversions, Traffic for pranavsharma.com ?
    I Will Findet…

    Don’t believe me? Since you’re reading this message then you’re living proof that contact form advertising works!
    We can send your ad to people via their Website Contact Form.


    IF YOU ARE INTERESTED, Contact us => lisaf2zw526@gmail.com


  10. DataTraveler says:

    Thanks a lot for posting this working example

  11. Hi, all is going sound here and ofcourse every one is
    sharing information, that’s in fact excellent, keep up writing.

  12. KumHereU ThinkAboutItThursday SelfMade oh_yalldntwannatalkaboutit_ok typeshit talent magazine
    hiphop rapbattle Dallas nyc Industry radio kaos business blogger Producer songwriter… … https://dallasvoipservice.com/

  13. whoah this weblog is excellent i love reading your posts.
    Keep up the great work! You know, many persons are hunting around for this information, you could help them greatly.

  14. Video is the content of choice for mobile consumers: Just four years ago,
    a quarter of the world’s population was watching video on their
    mobile devices — today it’s over 78 percent. Read more in Verve’s roundup of mobile marketing trends: https://todaysnewsrightnow.com/

  15. Doing a Monday review, loved this: Talking to Tech Support & they
    were in the PNW. I asked what their weather was like. They
    said 40’s & 6-8 inches of snow. I loved being able to report back that it was
    80 and sunny in Dallas. They will get the last laugh in August though… https://theboilerroomdallas.com

  16. Good reminder of (at least one reason) why his lawyers didn’t want him to sit and answer Mueller’s
    questions. https://lawyersofficedallastx.com/

  17. Я сегодня находился онлайн более трех
    часов, но я так и не нашел ни одной
    интересной статьи, подобной вашей.

    Это приятно удивило меня. Я полагаю, если все веб-мастера и блоггеры делали бы хороший контент,
    как вы, то полезных материалов появлялось бы более,
    чем достаточно.

  18. Вау! Я действительно наслаждаюсь сохраняя себе шаблоны и темы этого
    сайта. Они просты, но эффективны для оформления.

    Часто практически нереально найти “идеальный баланс” между удобством и визуальной составляющей ресурса.
    Я должен сказать, что этот человек проделал удивительную работу
    над материалом. Помимо этого, процесс
    загрузки потрясающе быстрый,
    у меня браузер Интернет Эксплорер.
    Превосходный блог!

  19. Ахтунг! Кто-то из подписчиков моей страницы в ВКонтакте подписан на автора этого аккаунта и
    может перейти туда, чтобы посмотреть увлекательные материалы?
    Я оставил закладку и обязательно
    поделюсь с моими подписчиками!

    Потрясающий блог, гармоничный дизайн и стиль.

Leave a Reply

Your email address will not be published.

Set your Twitter account name in your settings to use the TwitterBar Section.