Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3663

How can we store all document from Asp.net File Upload Control and store directly inti SharePoint list or library

$
0
0

How can we store from ASP.NET Application File Upload Control directly to SharePoint List / Library?

I have tried using Rest API call from ASP.net application but no luck. Getting

401 unauthorized access while accessing Request Digest in Your AJAX Request.

$.ajax({    url: "https://your-sharepoint-site/_api/contextinfo",    type: "POST",    headers: {"Accept": "application/json;odata=verbose"    },    success: function(data) {        var requestDigest = data.d.GetContextWebInformation.FormDigestValue;        console.log("Request Digest:", requestDigest);        // Now use this requestDigest in your subsequent AJAX call        performAjaxRequest(requestDigest);    },    error: function(error) {        console.log("Error retrieving request digest:", error);    }});function performAjaxRequest(requestDigest) {    $.ajax({        url: "https://your-sharepoint-site/_api/web/lists/getbytitle('YourList')/items",        type: "POST",        headers: {"Accept": "application/json;odata=verbose","X-RequestDigest": requestDigest        },        data: JSON.stringify({'__metadata': { 'type': 'SP.Data.YourListListItem' },'Title': 'New Item Title'        }),        contentType: "application/json;odata=verbose",        success: function(data) {            console.log("Item created successfully:", data);        },        error: function(error) {            console.log("Error:", error);        }    });}

Viewing all articles
Browse latest Browse all 3663

Trending Articles