0

I have used REST url as:

_api/web/Lists/GetByTitle('MediaGallery')/Items?$expand=Folder,File&$select=Title,FileSystemObjectType,Title_Ar,Folder/ServerRelativeUrl,Folder/Name,File/Name,File/ServerRelativeUrl

and i am getting result like this:

<?xml version="1.0" encoding="utf-8"?>
<feed xml:base="http://10.20.1.125/_api/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml">
    <id>42bd9282-169f-45c2-984e-aac92df68f69</id>
    <title />
    <updated>2015-08-07T05:59:15Z</updated>
    <entry m:etag="&quot;8&quot;">
        <id>Web/Lists(guid'f9c2b5d9-4abd-41d1-9f78-2dd342d12c06')/Items(66)</id>
        <category term="SP.Data.MediaGalleryItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
        <link rel="edit" href="Web/Lists(guid'f9c2b5d9-4abd-41d1-9f78-2dd342d12c06')/Items(66)" />
        <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/File" type="application/atom+xml;type=entry" title="File" href="Web/Lists(guid'f9c2b5d9-4abd-41d1-9f78-2dd342d12c06')/Items(66)/File" />
        <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Folder" type="application/atom+xml;type=entry" title="Folder" href="Web/Lists(guid'f9c2b5d9-4abd-41d1-9f78-2dd342d12c06')/Items(66)/Folder">
            <m:inline>
                <entry>
                    <id>Web/Lists(guid'f9c2b5d9-4abd-41d1-9f78-2dd342d12c06')/Items(66)/Folder</id>
                    <category term="SP.Folder" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
                    <link rel="edit" href="Web/Lists(guid'f9c2b5d9-4abd-41d1-9f78-2dd342d12c06')/Items(66)/Folder" />
                    <title />
                    <updated>2015-08-07T05:59:15Z</updated>
                    <author>
                        <name />
                    </author>
                    <content type="application/xml">
                        <m:properties>
                            <d:Name>Al Silaa Housing Project</d:Name>
                            <d:ServerRelativeUrl>/MediaGallery/Al Silaa Housing Project</d:ServerRelativeUrl>
                        </m:properties>
                    </content>
                </entry>
            </m:inline>
        </link>
        <title />
        <updated>2015-08-07T05:59:15Z</updated>
        <author>
            <name />
        </author>
        <content type="application/xml">
            <m:properties>
                <d:FileSystemObjectType m:type="Edm.Int32">1</d:FileSystemObjectType>
                <d:Title>Al Silaa Housing Project</d:Title>
                <d:Title_Ar>آل سلعا مشروع الإسكان</d:Title_Ar>
            </m:properties>
        </content>
    </entry>

and i trying to get these values using linq like this:

HttpResponseMessage response = await client.GetAsync(url);
                    //response.EnsureSuccessStatusCode();

                    if (response.IsSuccessStatusCode)
                    {

                        string data = await response.Content.ReadAsStringAsync();

                        StringReader reader = new StringReader(data);
                        XDocument responseXml = XDocument.Load(reader, LoadOptions.None);

                        XNamespace atom = "http://www.w3.org/2005/Atom";
                        XNamespace d = "http://schemas.microsoft.com/ado/2007/08/dataservices";
                        XNamespace m = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata";


                        var dataObjects = response.Content.ReadAsStringAsync().Result;

                        var items = from item in responseXml.Descendants(atom + "entry")
                                    select new
                                    {
                                        FolderNAme = item.Element(atom + "content").Element(m + "properties").Element(d + "Folder/Name").Value,

                                        FileSystemObjectType = item.Element(atom + "content").Element(m + "properties").Element(d + "FileSystemObjectType").Value,
                                       // GalleryDetails = item.Element(atom + "content").Element(m + "properties").Element(d + "GalleryDetails").Value,
                                        Title_Ar = item.Element(atom + "content").Element(m + "properties").Element(d + "Title_Ar").Value,
                                        Title = item.Element(atom + "content").Element(m + "properties").Element(d + "Title").Value

                                    };


                        var ItemList = items.ToList();


                    }

my question is, how to get value 'Folder/Name' and Folder/ServerRelativeURL

  • It'll be much easier if you return the items as JSON. Add Accept: application/json; odata=verbose and Content-Type: application/json; odata=verbose as headers to retrieve in json. See: stackoverflow.com/questions/8519788/… – Akhoy Aug 7 '15 at 7:18
  • I know, but what if i use xml, i am just stucked here – Isbah Khan Aug 7 '15 at 7:22

Your Answer

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

Browse other questions tagged or ask your own question.