none
Save the data in the file as json data RRS feed

  • Question

  • Hello,

    I need to read data from list / Pictures gallery / Documents  and save the returned data  in the file as json data .

    How Can I Implement that .


    ASk

    Tuesday, June 17, 2014 1:32 PM

Answers

  • Try below:

    http://msdn.microsoft.com/en-us/library/office/jj164022%28v=office.15%29.aspx

    The code in the following example shows you how to request a JSON representation of all of the lists in a site by using C#. It assumes that you have an OAuth access token that you are storing in the accessToken variable.

    HttpWebRequest endpointRequest = (HttpWebRequest)HttpWebRequest.Create(sharepointUrl.ToString() + "/_api/web/lists");
    endpointRequest.Method = "GET";
    endpointRequest.Accept = "application/json;odata=verbose";
    endpointRequest.Headers.Add("Authorization", "Bearer " + accessToken);
    HttpWebResponse endpointResponse = (HttpWebResponse)endpointRequest.GetResponse();
    
    

    Getting properties that aren't returned with the resource

    Many property values are returned when you retrieve a resource, but for some properties, you have to send a GET request directly to the property endpoint. This is typical of properties that represent SharePoint entities.

    The following example shows how to get a property by appending the property name to the resource endpoint. The example gets the value of the Author property from a File resource.

      http://<site url>/_api/web/getfilebyserverrelativeurl('/<folder name>/<file name>')/author

    To get the results in JSON format, include an Accept header set to "application/json;odata=verbose".


    If this helped you resolve your issue, please mark it Answered

    Tuesday, June 17, 2014 1:51 PM
    Moderator
  • you can use REST API to return the data to JSON format, to do so you need to set the Accept header to "application/json;odata=verbose"

    here is a step by step - http://blogs.technet.com/b/fromthefield/archive/2013/09/05/working-with-sharepoint-list-data-odata-rest-and-javascript.aspx

    http://msdn.microsoft.com/en-us/library/office/fp142380(v=office.15).aspx

    http://www.mindsharp.com/blog/2012/07/sharepoints-rest-an-odata-overview/

    http://sharepoint.stackexchange.com/questions/87452/display-json-results-from-rest-api

    see here for how to use REST API on files and folder - http://msdn.microsoft.com/en-us/library/office/dn292553(v=office.15).aspx

    The above link also has how to create a file by using this REST endpoint and the cross-domain library 


    Hope this helps!
    Ram - SharePoint Architect
    Blog - SharePointDeveloper.in
    Please vote or mark your question answered, if my reply helps you

    Tuesday, June 17, 2014 2:38 PM

All replies

  • what is your coding environment? .Net, JavaScript?

    in both environment, you can use REST call, specify the data format returned as JSON.


    John Architect

    Tuesday, June 17, 2014 1:46 PM
  • Try below:

    http://msdn.microsoft.com/en-us/library/office/jj164022%28v=office.15%29.aspx

    The code in the following example shows you how to request a JSON representation of all of the lists in a site by using C#. It assumes that you have an OAuth access token that you are storing in the accessToken variable.

    HttpWebRequest endpointRequest = (HttpWebRequest)HttpWebRequest.Create(sharepointUrl.ToString() + "/_api/web/lists");
    endpointRequest.Method = "GET";
    endpointRequest.Accept = "application/json;odata=verbose";
    endpointRequest.Headers.Add("Authorization", "Bearer " + accessToken);
    HttpWebResponse endpointResponse = (HttpWebResponse)endpointRequest.GetResponse();
    
    

    Getting properties that aren't returned with the resource

    Many property values are returned when you retrieve a resource, but for some properties, you have to send a GET request directly to the property endpoint. This is typical of properties that represent SharePoint entities.

    The following example shows how to get a property by appending the property name to the resource endpoint. The example gets the value of the Author property from a File resource.

      http://<site url>/_api/web/getfilebyserverrelativeurl('/<folder name>/<file name>')/author

    To get the results in JSON format, include an Accept header set to "application/json;odata=verbose".


    If this helped you resolve your issue, please mark it Answered

    Tuesday, June 17, 2014 1:51 PM
    Moderator
  • you can use REST API to return the data to JSON format, to do so you need to set the Accept header to "application/json;odata=verbose"

    here is a step by step - http://blogs.technet.com/b/fromthefield/archive/2013/09/05/working-with-sharepoint-list-data-odata-rest-and-javascript.aspx

    http://msdn.microsoft.com/en-us/library/office/fp142380(v=office.15).aspx

    http://www.mindsharp.com/blog/2012/07/sharepoints-rest-an-odata-overview/

    http://sharepoint.stackexchange.com/questions/87452/display-json-results-from-rest-api

    see here for how to use REST API on files and folder - http://msdn.microsoft.com/en-us/library/office/dn292553(v=office.15).aspx

    The above link also has how to create a file by using this REST endpoint and the cross-domain library 


    Hope this helps!
    Ram - SharePoint Architect
    Blog - SharePointDeveloper.in
    Please vote or mark your question answered, if my reply helps you

    Tuesday, June 17, 2014 2:38 PM