How, what and Why| X-RequestDigest (FormDigestValue) header value in SharePoint?

This value is get in to play mostly when we do POST, PUT, MERGE and DELETE requests via the SharePoint REST API. Unless you match with server digest value you won’t be able to perform the REST requests and it gives security validation issues (mostly 403 forbidden status).

How to get this value?

Send a POST request to below end point it will return the form digest value between “FormDigestValue”

http://<Site URL>/_api/contextinfo

What is X Request Digest (Form Digest Value)?

If you are not entitled to SharePoint using OAuth, your will require this value to authorize your request.

For more information: https://msdn.microsoft.com/en-us/library/office/fp142384.aspx

If you’re creating SharePoint hosted Add-in, you can take the digest value as below with JQuery

 Using JQuery

$("#__REQUESTDIGEST").val();

Using Angular JS

Sample Digest value :

0x5A846B1414597F46DB8E88D039E949D54BF62773B7E876730C1191F68240C935D57A17904E37992D2A78F9EC75AD462CF2C9AADFCDB30E1E044C1898358F04B6,13 May 2016 10:51:08 -0000May 2016 10:05:13 -0000

It’s specific to user, time period, site and changes time to time (basically it every 24 hours).

Further reading;

https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.formdigest.aspx

Advertisements

Startup with JQUERY

JQuery

jQuery is a JavaScript Library.
jQuery greatly simplifies JavaScript programming.
jQuery is easy to learn.
jQuery also simplifies a lot of the complicated things from JavaScript, like AJAX calls and DOM manipulation.
References:
http://jquery.com/download/
http://www.w3schools.com/jquery/jquery_examples.asp
http://www.w3schools.com/jquery/jquery_ref_selectors.asp

<!–Include one from following library //CDNs host JQuery libraries i.e. Google & Microsoft//–>
https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js
<!–OR–>
http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.3.min.js
<!–type=”text/javascript” inside the tag is not required in HTML5–>

$(selector).action()

Examples(Types of selectors):
$(this).hide() – hides the current element.
$(“p”).hide() – hides all

elements.
$(“.test”).hide() – hides all elements with class=”test”.
$(“#test”).hide() – hides the element with id=”test”.

//The Document Ready Event
$(document).ready(function(){
// jQuery methods go here…
//This is to prevent any jQuery code from running before the document is finished loading (is ready).
});
// or you can use following, both same
$(function(){
// jQuery methods go here…
//(document).ready clause is ommited here
});

//Selector examples
//Examples : http://www.w3schools.com/jquery/trysel.asp

//When a user

content, it will be hidden
$(document).ready(function(){
$(“p”).click(function(){
$(this).hide();
});
});

//when click on , content with

will be hidden
$(document).ready(function(){
$(“button”).click(function(){
$(“p”).hide();
});
});

<!–
Best practice to include all JQueries in seperate file and include that as follows
http://my_jquery_functions.js
–>

<!–
jQuery Event Methods [Actions]

*Juery is tailor-made to respond to events in an HTML page.
*Event actions as follows

Mouse Events Keyboard Events Form Events Document/Window Events
click keypress submit load
dblclick keydown change resize
mouseenter keyup focus scroll
mouseleave – blur unload

–>

<!–
jQuery Effects
http://www.w3schools.com/jquery/jquery_ref_effects.asp
–>

//Another hide() demonstration. How to hide parts of text.
$(document).ready(function(){
$(“.ex .hide”).click(function(){
$(this).parents(“.ex”).hide(“slow”);
});
});
//syntax: $(selector).hide(speed,callback);

//$(selector).show(speed,callback);
$(“#show”).click(function(){
$(“p”).show();
});

//Some more other JQuery Examples
//$(selector).toggle(speed,callback);
//$(selector).fadeIn(speed,callback);
//$(selector).fadeOut(speed,callback);
//$(selector).fadeToggle(speed,callback);
//$(selector).fadeTo(speed,opacity,callback)
//$(selector).slideDown(speed,callback);
//$(selector).slideToggle(speed,callback);
//$(selector).animate({params},speed,callback);

Introduction to JQUERY

WHAT :O ?

COOL!

It’s multi-browser JavaScript library(s) designed to simplify the client-side scripting of HTML

<refer this http://en.wikipedia.org/wiki/Jquery#Usage_styles ,if you need to get confused >

If you confused forget that !
lets see what we can do with this technology ;

WHAT KIND OF THINGS CAN BE DONE with this?

All the decorations in within web page can be done with this and so on(other thing will be discussed in a later post)!!

HOW TO USE ? 

Simple!

Just refer what you want from Jquery libraries and copy then paste on your page(inside code) or do as they says (Jquey is for make web developers life easy, So don’t be confused!).

RESOURCES and LIBRARIES FOR USE (reuse)?

 

Custom libraries 

follow this too (recommended to search required )

http://www.jqueryplugins.com/

some other sample gadgematics to refer >  

  • Supersized is a fullscreen background slideshow built using the jQuery library.

http://buildinternet.com/project/supersized/

  • Image slider and gallery

http://wowslider.com/

http://jquerytools.org/

If you need something more to know ,feel free to write me !

|kushanLahiru