SharePoint 2013 - getting list of files from a Document library in a site and sub-site - rest

I have encountered strange behavior in SharePoint 2013SP when using REST API to retrieve information about documents located Document libraries.
Here is a description of the issue, steps to reproduce are:
In the top-level site I create a sub-site called 'collab'.
I import two documents to the Documents library in the top-level site.
I import a new document to the Documents library in the 'collab'
subsite (just one document to somehow differentiate the two libraries).
I did it on a SharePoint 2013SP1 server - freshly installed.
Now, when I query the server to find documents in the 'collab' subsite I use the following REST call:
http://localhost/collab/_api/Web/lists/getByTitle('Documents')/Items
this returns 2 documents which are located in the top-level site Document library and not just the one document from the collab sub-site. Strange.
Exactly same result I get when I run this URL:
http://localhost/_api/Web/lists/getByTitle('Documents')/Items
Why SharePoint does not honor the subsite name in the URL?
At this point I thought that perhaps I am using a wrong endpoint, so I decide to try something else:
http://localhost/collab/_api/Web/GetFolderByServerRelativeUrl('/collab/Shared%20Documents')
This to my surprise returns correct number of documents: 1
Querying the top level site also returns correct number of items: 2.
http://localhost/_api/Web/GetFolderByServerRelativeUrl('/Shared%20Documents')
So now I try to retrieve information about the contents of the Document library of the top level site and the subsite:
First the top-level site:
http://localhost/_api/Web/GetFolderByServerRelativeUrl('/Shared%20Documents')/Files
this request gives correct response, there are two items.
Lets see if I get the same for the sub-site:
http://localhost/collab/_api/Web/GetFolderByServerRelativeUrl('/collab/Shared%20Documents')/Files
Sadly, I get a response which is difficult for me to understand:
<feed xml:base="http://localhost/_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>8f772a2c-2d90-4324-9168-3344aedca14b</id>
<title/>
<updated>2018-01-28T11:37:22Z</updated>
<author>
<name/>
</author>
</feed>
What does this response mean?
When I try a slightly different URL:
http://localhost/collab/_api/Web/GetFolderByServerRelativeUrl('/Shared%20Documents')/Files
I get in the response details about the documents which are in the top level site, even though I have 'collab' site name in the URL. What is going on here?
Questions are:
How do I retrieve list of documents for the site and subsite Documents library in a consistent manner? What REST API endpoint should I use?
Why above REST API calls return only those documents which are in the top-level Document library site ignoring the subsite's Document library?
Thanks!
Karol

Get files from documents library in root site using the following REST URL:
http://localhost/_api/Web/GetFolderByServerRelativeUrl('Shared%20Documents')/Files
Get files from documents library in sub site("collab") using the following REST URL:
http://localhost/collab/_api/Web/GetFolderByServerRelativeUrl('Shared%20Documents')/Files
If it still not works, I suggest you update the latest CU for SharePoint 2013.
Latest Updates for SharePoint 2013

Related

How to get version history of a file in folder in sharepoint using SharePoint REST API using c#?

I have a SharePoint library with a file in it. I need to get previous versions of the file who created it and when. What is the rest endpoint to fetch those details. I am new to SharePoint. Please help
You could use this rest endpoint to get previous versions of the file by the file id:
https://<server>/sites/<site>/_api/web/lists/getByTitle('Documents')/items(1)/versions
You could add filters at the end to get the information you need:
https://<server>/sites/<site>/_api/web/lists/getByTitle('Documents')/items(1)/versions?$select=VersionLabel,Created_x005f_x0020_x005f_By,Created
in order to get additional information from REST API request You need to use the $expand property. If You need information like who made the update please add '?$expand=CreatedBy' at the end of the request.. so for Your example it will be something like:
https:///sites//_api/web/GetFolderByServerRelativeUrl('Shared%20Documents/general')/files('SampleDocFile.docx')/versions?$expand=CreatedBy
that way You will have the user who modified the file in
content>properties>Title
other interesting data is:
updated>
content>properties>CheckInComment>
content>properties>VersionLabel>

What is the ALM REST URL for the list of users under a project

I am trying to get the users which are availale for assignment under an ALM project. The same list of users you get when you click the "Assigned to" and "Assigned to (name)" headers in the browser client of ALM.
I have searched around the web trying to find a resource for this, but without luck. I have also tried to guess, e.g. like:
https://url/qcbin/api/domains/domain/projects/project/users or https://url/qcbin/api/domains/domain/projects/project/accounts etc.
Using ALM 12.21
Anyone knows?
Please have a look at the customization command, for instance:
Description
The data on the specified project user.
URL
/qcbin/rest/domains/{domain}/projects/{project}/customization/users/{user name}
Operation to be performed is a GET in this case. You can refer to the REST API documentation.
This gives you the project users. Hope this clarify your query! Have a nice day.

Import API not working in sisense

I was trying to use the dashboard import API from v1.0 which can be found in the REST API reference. I logged in to http://localhost:8083/dev/api/docs/#/ , gave the correct authorization token, and a dash file in the body, and a 24 character importFolder and hit the Run button to fire the API. It returns 201 as HTTP response, which means the request was successful. However, when I go back to the homepage, I don't see any new dashboard imported in to the said folder. I have tried both cases, where the importFolder exists (already created manually be me), and does not already exist, where I expect the API to create it for me. Neither of these, however, create/import the dashboard
A few comments that should help you resolve this:
When running the command from the interactive API reference (swagger) you don't need the authentication token, because you're already logged in with an active session.
Make sure the json of your dashboard is valid, by saving it as a .dash file and importing via the UI
The folder field is optional - if you leave the field blank, the dashboard is imported to the root of your navigation/folders panel.
If you'd like to import to a specific folder, you'll need to provide the folder ID, not its name, which can be found several ways such as using the /api/v1/folders endpoint, where you can provide a name filtering field and use the oid property of the returned object as the value for the folder field in the import endpoint.
If you can't get this to work still, use chrome's developer tools to look at the outgoing request when you import from the UI and compare the request (headers, body and path) to what you're doing via swagger in order to find the issue.

URL query returns results in browser, but CSV export doesn't take in filters

I'm trying to pull some data from a site into a sharepoint site using REST. The query filters work in browser, but when CSV= is added to the front it exports everything and ignores the filters.
This works
sysparm_query=company%3D9a641cf40a0a3cc201ef8ad1b4c88cf9%5Eoperational_status%3D1%5EnameLIKEPROD&sysparm_first_row=1&sysparm_view=
This doesn't
CSV=sysparm_query=company%3D9a641cf40a0a3cc201ef8ad1b4c88cf9%5Eoperational_status%3D1%5EnameLIKEPROD&sysparm_first_row=1&sysparm_view=
For Web Service calls, the CSV is handled as a separate parameter. I'd recommend trying the following:
sysparm_query=company%3D9a641cf40a0a3cc201ef8ad1b4c88cf9%5Eoperational_status%3D1%5EnameLIKEPROD&sysparm_first_row=1&sysparm_view=&CSV
Note that I included &CSV at the end

Get Alfresco document nodeRef and versionNodeRef together

I'm using Alfresco Community 5.0b. I have a web application that uses Alfresco for its document store. Each time I create a new document or update an existing version of a document, I want to store in my application database the document ID and the version ID. The call to upload the document:
POST /alfresco/service/api/upload works great in that it returns the nodeRef of the newly created document, but it doesn't return the version nodeRef. To get that, I need to then call: GET /alfresco/service/api/version?nodeRef={nodeRef}
Is there a way to get both pieces of information in a single call?