HTTP 403 while using SharePoint Online REST API anonymously

Hey Team,
While using REST API to get list items (SharePoint Online) anonymously, I am getting HTTP 403 error:
Request: http://server/site/_api/web/lists('guid')/items?$select=Title,Products/Name&$expand=Products/Name
Response: HTTP 403 : System.UnauthorizedAccessException : Access denied. You do not have permission to perform this action or access this resource.
Authenticated users do not face this issue. The list has anonymous access (View) enabled. Anonymous users can access the lists without facing any issue.
I am not sure and could not able to find any link that says anonymous users can't use REST API to get SPListItems. Any input in this regard will be highly appreciated.
Regards,
Sanjay
Either you love IT or leave IT

Hi,
From this documentation from MSDN about
Reading data with REST, “Note that you cannot obtain an access token from code that is running on a browser client. You must obtain the access token from code that is running
on a server”, it will only allow the authenticated users who has an access token to access the REST API.
The two links below will provide more information about authentication in SharePoint 2013:
http://msdn.microsoft.com/en-us/library/fp142382.aspx
http://msdn.microsoft.com/en-us/library/jj687470.aspx
Thanks
Patrick Liang
Forum Support
Please remember to mark the replies as answers if they
help and unmark them if they provide no help. If you have feedback for TechNet
Subscriber Support, contact [email protected]
Patrick Liang
TechNet Community Support

Similar Messages

  • Return data is null while calling Exchange Online rest api using jquery on Chrome and Mozilla

    Hi,
         I am developing a SharePoint hosted app in which I am calling Exchange online rest api using basic authentication to get mail for the user. This works fine in IE but returns null data when opening in Chrome or Mozilla.
    Is there something I am missing while making rest call to api?
    Please remember to mark your question as answered &Vote helpful,if this solves/helps your problem. Thanks, Ajeet

    Hi,
    This forum is to discuss problems of Office development such as VBA, VSTO, Apps for Office .etc. But I think your question is related to app for SharePoint. I suggest you posting it in
    App for SharePoint forum for more efficient responses.
    Thanks.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • POST to SharePoint Online REST API - 405 Method Not Allowed

    Good afternoon,
    I am writing C# with the intention of uploading a file to a document library using the REST API.
    The code must run on an on-premise machine and the target SharePoint site is in SharePoint Online (Office 365 E-plan).  It has to handle large files, so CSOM is not an option.
    I have successfully tested a few different "get" messages, so I believe the authentication part is working.  However, so far I have no such luck with POST.
    In fiddler, my most recent attempt looks like this (I redacted the parts in <> because I'm not sure if they are sensitive somehow):
    POST http://org.sharepoint.com/sites/site/_api/web/GetFolderByServerRelativeUrl('Documents')/Files/add(url='test2.txt',overwrite=true) HTTP/1.1
    Accept: application/json;odata=verbose
    X-RequestDigest: <digest value>,15 Jan 2014 17:48:49 -0000
    BinaryStringRequestBody: true
    Host: org.sharepoint.com
    Content-Length: 6
    Expect: 100-continue
    stuff!
    Seems like it should work, but the result is "301 Moved Permanently."  This request is immediately followed by this one: 
    GET https://org.sharepoint.com/sites/site/_api/web/GetFolderByServerRelativeUrl('Documents')/Files/add(url='test2.txt',overwrite=true) HTTP/1.1
    Accept: application/json;odata=verbose
    X-RequestDigest: <formdigest>,15 Jan 2014 18:01:51 -0000
    BinaryStringRequestBody: true
    Host: org.sharepoint.com
    Cookie: FedAuth=<cookiestuff>; rtFA=<cookiestuff>
    Response:
    HTTP/1.1 405 Method Not Allowed
    Cache-Control: private, max-age=0
    Transfer-Encoding: chunked
    Content-Type: application/json;odata=verbose;charset=utf-8
    Expires: Tue, 31 Dec 2013 18:01:52 GMT
    Last-Modified: Wed, 15 Jan 2014 18:01:52 GMT
    Server: Microsoft-IIS/7.5
    X-SharePointHealthScore: 0
    X-SP-SERVERSTATE: ReadOnly=0
    SPClientServiceRequestDuration: 25
    X-AspNet-Version: 4.0.30319
    SPRequestGuid: dd936a9c-f4fc-a05d-27e1-2c948f0eb575
    request-id: dd936a9c-f4fc-a05d-27e1-2c948f0eb575
    X-FRAME-OPTIONS: SAMEORIGIN
    X-Powered-By: ASP.NET
    MicrosoftSharePointTeamServices: 16.0.0.2308
    X-Content-Type-Options: nosniff
    X-MS-InvokeApp: 1; RequireReadOnly
    P3P: CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI"
    Date: Wed, 15 Jan 2014 18:01:51 GMT
    128
    {"error":{"code":"-1, Microsoft.SharePoint.Client.ClientServiceException","message":{"lang":"en-US","value":"The HTTP method 'GET' cannot be used to access the resource 'Add'. The operation type of the resource is specified as 'Default'. Please use correct HTTP method to invoke the resource."}}}
    0
    So it looks to me as if my request is being redirected to the same address but with a "GET" method rather than "POST," resulting in the 405 Method Not Allowed error because "add" needs POST.
    I appreciate any insight you can offer.

    Mkay, perhaps I should rephrase:  
    I want to synchronize a SharePoint Online library with a local file share.  There are a large quantity of files, and many of them are large (actually it's all too large to fit in one SharePoint Online site collection due to the 100gb limit, but I'll
    deal with that separately).
    The approach I was working on here was to create a C# method basically like this:  UploadFile(File, Destination, username, password).  I would use this method in the script component of an SSIS package which would run on a server and push the files
    up to SPO, but right now I'm just testing it as a console application.
    I got the CSOM methods working, but obviously that won't work because the files are too large.  Above is what's happening with the REST version.
    Can anyone see what's wrong with my REST calls - why is it being redirected as a GET request?  Is this even possible?

  • Sharepoint 2013 REST API calls with JASONP support

    We are working on sharepoint online integration with PHP Based application. We need to provide REST API call which supports JSONP.
    So is it possible to create new REST API Endpoints in Sharepoint online APP? Please sugggest right direction.

    Hi,
    In Office 365 (aka SharePoint Online), you can simply consume the SharePoint data through REST API or WS call,but cannot create your own endpoint.
    By default you can get the JSON response from the Office 365 REST API,its upto you to use the JSONP on your client compatibility not on SharePoint online REST API.
    Sometime before I tried, It didn't work for me.
    If you develop the AppModel, SPRequestor.js does the same job(overcome the Cross domain restriction) the what JSONP does.
    Murugesa Pandian| MCPD | MCTS |SharePoint 2010

  • SharePoint 2013 REST API with C# - Mapping HTTP verbs to data operations - Requesting FormDigest

    SharePoint REST interface maps HTTP verbs to data operations. Endpoints that represent
    Read operations map to HTTP
    GET commands. Endpoints that represent update operations map to HTTP
    POST commands, and endpoints that represent update or insert operations map to HTTP
    PUT commands (Ref:
    How to: Complete basic operations using SharePoint 2013 REST endpoints).
    Is this mapping of HTTP verbs to CRUD operations a design paradigm or whether there are other technical reasons to this mapping
    Is is possible to use a GET command for say an update operation or a POST for say a read operation.If so, what consideration make the choice of either usage
    In the code snippet below FormDigest is requested as POST, why not use GET here?
    private static string GetFormDigest(string webUrl)
    //Validate input
    if (String.IsNullOrEmpty(webUrl) || String.IsNullOrWhiteSpace(webUrl))
    return String.Empty;
    //Create REST Request
    Uri uri = new Uri(webUrl + "/_api/contextinfo");
    HttpWebRequest restRequest = (HttpWebRequest)WebRequest.Create(uri);
    restRequest.Credentials = CredentialCache.DefaultCredentials;
    restRequest.Method = "POST";
    restRequest.ContentLength = 0;
    //Retrieve Response
    HttpWebResponse restResponse = (HttpWebResponse)restRequest.GetResponse();
    XDocument atomDoc = XDocument.Load(restResponse.GetResponseStream());
    XNamespace d = "http://schemas.microsoft.com/ado/2007/08/dataservices";
    //Extract Form Digest
    return atomDoc.Descendants(d + "FormDigestValue").First().Value;
    Thanks - Abhishek

    Many SharePoint REST api methods use parameters. It is much more efficient to post parameters than use query string variables.  Many times complex types are sent and these require json notation objects posted in the body. In the case of "_api/contextinfo,
    it is recommended to use POST rather than a GET when using sensitive data. GET responses can be cached. Since you are getting a security token back in that call it is recommended to use a POST.
    http://blog.teamtreehouse.com/the-definitive-guide-to-get-vs-post
    Blog | SharePoint Field Notes Dev Tools |
    SPFastDeploy | SPRemoteAPIExplorer

  • SharePoint 2010 Rest API: How to add attachment to a list item via ListData.svc

    Hi
    I have set up a project using the REST API in c# Visual Studio 2010.
    I have added a service reference to the URL //site/_vti_bin/listdata.svc/
    I can query the list and get back data, but I can't retrieve the attachments.
    I can write data to the list, but I can't add attachments.
    Are there any examples of how to add or retrieve attachments using the REST API services.
    Thanks
    Mike

    Hi,                                                             
    If you want to work with list attachments using REST API, here are some links will show how to do this using Javascript:
    http://msdn.microsoft.com/en-us/library/office/dn292553.aspx#FileAttachments
    http://chuvash.eu/2013/02/20/rest-api-add-a-plain-text-file-as-an-attachment-to-a-list-item/
    http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2013/06/27/how-to-get-list-item-attachments-using-rest-and-javascript-in-sharepoint-2013.aspx
    Best regards
    Patrick Liang
    TechNet Community Support

  • Determine Email of the person in the people field using JSOM or REST API

    Hi,I have to build below HTML dynamically. The source to build this is a sharepoint list that has a people field in it.Can I use JSOM or REST API to do this? if so, can anyone help with some examples?<a href='mailto:[email protected],[email protected]'>Write email</a>
    techie

    Hi,
    The following code for your reference:
    <script src="http://code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(function () {
    var array=new Array();
    var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('CustomList')/items?$select=EmployeeId";
    // execute AJAX request
    $.ajax({
    url: requestUri,
    type: "GET",
    headers: { "ACCEPT": "application/json;odata=verbose" },
    success: function (data) {
    var dataResults = data.d.results;
    for(var i=0;i<dataResults.length;i++){
    if(dataResults[i].EmployeeId!=null){
    for(var j=0;j<dataResults[i].EmployeeId.results.length;j++){
    array.push(dataResults[i].EmployeeId.results[j]);
    //remove the duplicated id
    var employeeIds=$.unique(array);
    //get the employee email by user id
    var emails=getEmailsByIDs(employeeIds);
    //add to send mail div
    $("#SendMail").append("<a href='mailto:"+emails+"'>Send Email</a>");
    error: function () {
    //console.log("Failed to get details");
    function getEmailsByIDs(employeeIds){
    var emails=new Array();
    var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/siteusers?$select=Id,Email";
    // execute AJAX request
    $.ajax({
    url: requestUri,
    type: "GET",
    headers: { "ACCEPT": "application/json;odata=verbose" },
    async: false,
    success: function (data) {
    var dataResults=data.d.results;
    for(var i=0;i<dataResults.length;i++){
    for(var j=0;j<employeeIds.length;j++){
    if(dataResults[i].Id!=null&&dataResults[i].Id==employeeIds[j]&&dataResults[i].Email!=null){
    emails.push(dataResults[i].Email);
    error: function () {
    //console.log("Failed to get details");
    return emails;
    </script>
    <div id="SendMail">
    </div>
    Thanks,
    Dennis Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected].
    Dennis Guo
    TechNet Community Support

  • Extracting Raw Data Using Excel Services REST API

    I am trying to create a home page in SharePoint 2013 that shows quick stats based on an Excel workbook stored in a document library. Through my research I found that I could leverage the Excel Services REST API to pull the information I need from the workbook
    via URIs and display it on a SharePoint page in a seamless manner.
    The problem I am having is pulling the data I need as raw text.
    For example, I can create a page in HTML that says "Our sales for the month grew by [X%]" and use an img src tag that points to
    http://sample.com/_vti_bin/ExcelRest.aspx/Documents/workbook.xlsx/Model/Ranges('Sheet1!A1')?$format=image to show a picture of cell A1 which contains the data I want to show inline on my page.
    I want a way to pull the data in cell A1 as raw text so that I can format it as part of the HTML page. I tried using
    $format=html, but that just takes me to a separate page where the cell is formatted exactly as it is in the workbook.
    Is there a way to do what I am trying to do? The more detailed your response can be, the better as I am fairly new to these features. And also, is there a way to perform calculations of cells in HTML? Thanks in advance.

    Hi,
    According to your description, you might want to extract text value from a specific cell in an Excel file using Excel Services REST API.
    As there is no such predefined format can be used to return text value only, I would suggest you return the value as json format, then parse it and set to your HTML
    tag using jQuery.
    Here is a <p> tag with a script which can set the value of the <p> tag with the value gets from cell “A1”:
    <p id="cell1">test</p>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
    <script type="text/javascript">
    //replace the strings below with yours
    var libName = "Shared Documents";
    var fileName = "Book1.xlsx";
    var rangeName = "A1";
    $(function(){
    var s = getCellValue(libName, fileName, rangeName);
    $("#cell1").html(s);
    function getCellValue (libName, fileName, rangeName)
    var cell = "";
    $.ajax({
    url: _spPageContextInfo.webAbsoluteUrl + "/_vti_bin/ExcelRest.aspx/"+libName+"/"+fileName+"/model/Ranges('"+rangeName+"')?$format=json",
    method: "GET",
    headers: { "Accept": "application/json; odata=verbose" },
    dataType: "json",
    async: false,
    success: function (data) {
    console.log(data.rows[0][0].v);
    cell = data.rows[0][0].v;
    error: function (data) {
    console.log(data);
    return cell;
    </script>
    You can add it into your page via a Content Editor Web Part, it will take effect after the page loaded.
    Here are two links about how to add code into page via Content Editor Web Part:
    http://blogs.msdn.com/b/sharepointdev/archive/2011/04/14/using-the-javascript-object-model-in-a-content-editor-web-part.aspx
    http://sharepointadam.com/2010/08/31/insert-javascript-into-a-content-editor-web-part-cewp/
    Best regards
    Patrick Liang
    TechNet Community Support

  • How to read azure storage data using JAVA with REST API

    Hi,
    We have a cloud service in our lab. We have enabled diagnostics
    in cloud services. So WADPerformanceCounterTable was created in storage account. Now , We want to read the WADPerformanceTable using
    JAVA with REST API. Is there any way to collect these details. please give me any
    sample code to connect azure storage using table service REST API.
    Thanks & Regards
    Rathidevi

    Hi,
    Please have a look at this article:
    https://convective.wordpress.com/2010/08/18/examples-of-the-windows-azure-storage-services-rest-api/, it demonstrate how to use table service Rest API, it also give us the code, hope this helps. Of course, the
    MSDN article could also help us coding.
    Best Regards,
    Jambor
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to watch forum using Webcenter Discussions REST API

    If I am building an application using WebCenter Discussions REST API, what API should I invoke to watch forum, topic? If it is not available in the REST API, what is the workaround to do the same ?
    Did not find relevant information in the [http://docs.oracle.com/cd/E23943_01/webcenter.1111/e10148/jpsdg_jive.htm#CHDGJECD] .

    Hi.
    REST Discussions API allow you to get all information that you need. It provides URL to Forums, topics... Or directly you can access to the messages.
    In addition, you can use REST Search API to search into discussion forums if you have Oracle SES.
    Off doc about information that can you get through REST API: http://docs.oracle.com/cd/E23943_01/webcenter.1111/e10148/jpsdg_jive.htm#CHDGJECD
    In the case of that you need more information about provided by REST API or WebCenter API then you can implement your own ADF BC to consume Discussions schema :).
    Regards.
    Edited by: Daniel Merchán on 16-oct-2012 15:16

  • Performance issue during SharePoint list data bind to html table using Ajax call(Rest API)

    Hello,
    I am having multiple lists in my SharePoint Site. I am using SharePoint REST APIs to get data from these lists and bind a HTML Table. Suppose, I have 5 lists with 1000 records each, I am looping 5000 times to bind each row(record) to this html table. This
    is causing performance issue which is taking a very long time to bind. 
    Is there any way So that I can reduce this looping OR is there any better approach to improve the performance. Please kindly Suggest.  Thank you for your help :)
    Warm Regards,
    Ratan Kumar Racha

    Hi Racha,
    For handling large data binding in a page,
    AngularJS would be a great option if you might would worry about the performance.
    You can get more information about using AngularJS from the two links below:
    https://www.airpair.com/angularjs/posts/angularjs-performance-large-applications
    http://www.sitepoint.com/10-reasons-use-angularjs/
    Best regards
    Patrick Liang
    TechNet Community Support

  • How to Create, Edit, and delet Alerts in sharepoint using COM or REST API

    I need to create,Delete and  Alerts using Client object model or REST API , I know It's available on server objetc model , but in client side how do it , 
    Anu ideas 

    Hi,
    According to your description, my understanding is that you want to create, delete and edit SharePoint alerts using Client Object Model or Rest API.
    In SharePoint Client Object Model, there is very little that you can achieve when it comes to alerts.
    For changing alerts, there is a ChangeAlert class:
    change alert class
    For Deleting alerts, you can call deletealert web service:
    DeleteAlerts
    For creating new alerts, it seems no such API support this, a workaround is call the new alert form "SubNew.aspx" using JavaScript to achieve it.
    More information:
    http://www.learningsharepoint.com/2013/09/17/client-object-model-doesnt-support-creating-sharepoint-2013-alerts/
    Thanks
    Best Regards,
    Jerry Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Call an Non-SharePoint Secured RESTful API from a Workflow in a SharePoint Online Tenant

    I have a scenario where I need to be able to make calls to a secured web service from a SharePoint 2013 workflow that will be deployed in a SharePoint Online (Office 365) environment. It is a REST web service that is secured in a 2-legged OAuth-like manner
    (the service expects a hash of the data being sent that can then be validated on the service's end of the communication). The problem is, I can't figure out how I can hash the data, since I can't run any server-side code in the SharePoint Online environment.
    The way I figured this should work is 1) user creates an item in a List on the SharePoint Site, which kicks off the workflow process. 2) the workflow process takes the user data and hashes it using a client secret assigned by the web service. 3) the
    workflow creates a web request to the web service, passing the data and the hashed values. 4) the web service processes the input and returns. 5) the workflow continues to the next step.
    I can't figure out how to implement step 2 in that process. I thought I could do a custom workflow activity that would accomplish it, but since it would pretty much have to be a code-based activity (i.e., not declarative), it can't be deployed in SharePoint
    Online, according to the domentation I've found. I could potentially add a third layer in the process and have an auto-hosted app that I could call to do the hashing of the data, but that seems to defeat the purpose somewhat from a security perspective.
    Has anyone else run into this kind of scenario? Doing this in an on-premesis environment would be easy, but that's not really an option.
    Thanks!

    You should implement this by passing the values to a public (forms based auth) web method (secure over SSL) that does the hash for you and returns the value to your workflow so that it can pass it on to the other service.
    Chris Givens CEO, Architecting Connected Systems
    Blog Twitter

  • SharePoint 2010 REST API, User SiteColumn not coming

    When Create User sitecolumn from front end(using default SharePoint Setting area) and then fetch list through REST API then it comes parfactly but
    When I create User sitecolumn's xml from Visual Studio and then add that sitecolumn in contenttype and then in list and then fact list through REST API then it does come in api xml.

    Hi Manish<o:p></o:p>
     <o:p></o:p>
    I can understand your issue, but not sure what could be the reason behind this behavior. To help you resolve the issue, we will need troubleshooting to be done at your end. I would request you
    to open a support ticket with Microsoft to help us resolve your issue as quickly as possible.
    For more information about Microsoft Support please read the article http://support.microsoft.com/gp/proffaq/en-gb
     <o:p></o:p>
    Thanks,
    Bharat Rathod, <u1:p></u1:p><o:p></o:p>
    Microsoft Online Community Support<u1:p></u1:p><o:p></o:p>

  • Trying to Access SharePoint 2013 Rest Api in HTML page but getting Mime Type Exception with Status Success

    I am trying to invoke the SharePoint Rest Api using HTML page. I have included the Access Control Allow Origin to the web.config file. I am getting Readty State 4 and
    Status Success but still I am getting the below error.
    Refused to execute script from 'http://<server>/_api//web/lists?callback=jQuery172045857910416089_1430217181282&_=1430217363882' because its MIME
    type ('application/atom+xml') is not executable, and strict MIME type checking is enabled.
        <script>
            $(document).ready(function () {
                $("#KMPDiscussions").click(function () {
                    //$.support.cors = true;
                    $.ajax({
                        url: "http://<server>/_api//web/lists",
                        dataType: "jsonp",
                        type: "GET",
                        method: "GET",
                        contentType: "application/javascript",
                        headers: {
                            "content-type":
    "application/json;odata=verbose",
                            "accept": "application/json;odata=verbose",
                        success: function onSuccess(data) {
                            alert("Inside Alert");
                        error: function onError(data){
                            alert("Error: "
    + data);
        </script>
    It always hits the error on callback.
    Is there any other way that I can invoke SharePoint Rest Api from a Cross Domain. Please Help.

    Hi Chris,
    Thanks for the reply,Here iam using different files to be uploaded in library.
    please find the below snapshot of json response and ULS logs.
    12/22/2013 18:31:15.02 w3wp.exe (0x3338) 0x401C SharePoint Foundation Files 
    abq2i High Could not get DocumentContent row: 0x80004005. 79f7629c-4694-c026-
    3349-2049178ee919
    12/22/2013 18:31:15.02 w3wp.exe (0x3338) 0x401C SharePoint Foundation Files 
    aiv4w Medium Spent 0 ms to bind -1 byte file stream 79f7629c-4694-c026-3349-
    2049178ee919 
    12/22/2013 18:31:15.02 w3wp.exe (0x3338) 0x401C SharePoint Foundation Files 
    aise3 Medium Failure when fetching document. 0x80070012 79f7629c-4694-c026-
    3349-2049178ee919
    12/22/2013 18:31:15.39 w3wp.exe (0x3338) 0x0D4C SharePoint Foundation 
    Database ab1a9 High Failed to get document content data.
    System.ComponentModel.Win32Exception (0x80004005): Cannot complete this function     at
    Microsoft.SharePoint.SPSqlClient.GetDocumentContentRow(Int32 rowOrd, Object
    ospFileStmMgr, SPDocumentBindRequest& dbreq, SPDocumentBindResults& dbres) 
    79f7629c-76ab-c026-3349-2c9132b13e9a
    12/22/2013 18:31:15.39 w3wp.exe (0x3338) 0x4184 SharePoint Foundation 
    Database ab1a9 High Failed to get document content data.
    System.ComponentModel.Win32Exception (0x80004005): Cannot complete this function     at
    Microsoft.SharePoint.SPSqlClient.GetDocumentContentRow(Int32 rowOrd, Object
    ospFileStmMgr, SPDocumentBindRequest& dbreq, SPDocumentBindResults& dbres) 
    79f7629c-76ab-c026-3349-281167b6cd09
    Thanks again,
    Naresh.

Maybe you are looking for