I am trying to delete a web by calling the REST service from a SharePoint 2013 workflow. The MSDN reference here tells the syntax is like below:

  url: "http://<site url>/_api/web",
  type: "POST",
  headers: { 
    "X-RequestDigest": <form digest value>,
    "X-HTTP-Method": "DELETE"
  success: successHandler,
  error: errorHandler

But, I am not famililiar how to get 'form digest value'.

Can anyone assist on this?


You should rename the question to "How to get form digest value"...

There are two ways to get the form digest value:

  1. Get the form digest value from the page: document.getElementById("__REQUESTDIGEST").value
  2. Invoke a post request to get the context info

    $.ajax({url: "<site_url>/_api/contextinfo", 
       header: {
            "accept": "application/json; odata=verbose", 
            type: "POST", 
            contentType: "application/json;charset=utf-8"
     }).done(function(d) {
             //run your code
  • 1
    I guess the OP is asking about solution for SPD Workflow.. – Vadim Gremyachev Sep 8 '14 at 13:10

You can do this in SPD but it is a little less straightforward than using jQuery.

The below page has a tutorial that I can confirm still works with SharePoint Server 2016.

The gist of that page is reproduced here:

  1. Create Build new Dictionary action outputting to a Dictionary called header

  2. Create two keys in header with these values:

    • Accept: application/json; odata=verbose
    • Content-Type: application/json; odata=verbose
  3. Add a Call HTTP Web Service action and configure like so:

    • Url: [%site url%]_api/contextinfo
    • Type: POST
    • Request Header: header
    • Response Content: ResponseContent (new Dictionary variable)
  4. Add a Get Item from Dictionary activity & configure like so:

    • Path: d/GetContextWebInformation/FormDigestValue
    • From: ResponseContent
    • Output: DigestID (new String variable)

This will give you a String variable containing the Request Digest ID, which you can then use in subsequent HTTP POST actions.

Source: https://saberghanmien.wordpress.com/2018/06/06/sharepoint-designer-call-http-web-service-with-requestdigest/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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