SharePoint REST API getFolderByServerRelativeUrl Returns Nothing - api

I would like to drill into the library and then into a specified folder, but I am having problems getting 'getFolderByServerRelativeUrl' to grab anything for me.
This http://_base/_api/web/getFolderByServerRelativeUrl('LibName')/files returns zero results. But if I use http://_base/_api/web/lists/getbytitle('LibName')/items it returns multiple items.

/_api/web/lists/getbytitle('<list title>')/items endpoint returns all list items within a library, /_api/web/getFolderByServerRelativeUrl('<url>')/files returns only files located under (one level beneath only) the specified folder.
Example
Assume the following Documents library structure:
Documents (library)
|
Guides (folder)
|
SharePoint User Guide.docx (file)
Then, the following request:
/_api/web/lists/getbytitle('Documents')/items will return 2 items:
list item associated with Guides folder
list item associated with file
At the same time, the request: /_api/web/getFolderByServerRelativeUrl('Documents')/files
will returns 0 files since there are no files contained in the root folder
but the request with provided folder url:
/_api/web/getFolderByServerRelativeUrl('Documents/Guides')/files
will return SharePoint User Guide.docx file.

You're using the wrong URL. Try appending it to the other URL.

Related

Get File Structure from Get Metadata in ADF

I want to get the column names for a parquet file. I have a Get Metadata module in my pipeline and it is using a parquet dataset with only the root folder provided. Because only the folder is provided ADF is not letting me get the file structure that contains the column names. The file name is not provided because that can change. Can anyone provide some advice on how to approach this?
You will need 2 Get Metadata activities and a ForEach activity to get the file structure if your file name is not the same every time.
Source dataset:
Parameterize the file name as the name changes frequently.
Preview of source data:
Get Metadata1:
In the first Get Metadata activity, get the file name dynamically.
You can also specify if your file name contains any specific pattern by adding an expression in the filename or you can mention asterisk (*) if you don’t have a specific pattern or need more than 1 file in the folder needs to be processed.
Give field list as child items when you want to get the files from the folder.
Output of Get Metadata1: Get the file name from the folder.
FoEach activity:
Using the ForEach activity, you can get the item's name listed inside the Get Metadata activity output array.
Get Metadata2:
Add Get Metadata activity inside ForEach activity to get the file structure or column list of the current file from the folder. It can loop the number of items count in the folder (1 or more).
Output of Get Metadata2:
You can parameterize your file name in dataset or via GetMeta data activity, get the list of files within the folder and then via GetMetaData activity get the list of columns for those corresponding files.

Is there a way to list the directories in a using PySpark in a notebook?

I'm trying to see every file is a certain directory, but since each file in the directory is very large, I can't use sc.wholeTextfile or sc.textfile. I wanted to just get the filenames from them, and then pull the file if needed in a different cell. I can access the files just fine using Cyberduck and it shows the names on there.
Ex: I have the link for one set of data at "name:///mainfolder/date/sectionsofdate/indiviual_files.gz", and it works, But I want to see the names of the files in "/mainfolder/date" and in "/mainfolder/date/sectionsofdate" without having to load them all in via sc.textFile or sc.Wholetextfile. Both those functions work, so I know my keys are correct, but it takes too long for them to be loaded.
Considering that the list of files can be retrieve by one single node, you can just list the files in the directory. Look at this response.
wholeTextFiles returns a tuple (path, content) but I don't know if the file content is lazy to get only the first part of the tuple.

Download Multiple Attachments from Salesforce using Jitterbit

I am able to create a query for attachments and download 1 individual file like this:
SOQL:
SELECT Body, Id FROM Attachment WHERE Id = '00P4M00000q8ChI'
Code on Body:
<trans>$content = root$transaction.response$body$queryResponse$result$records.Attachment$Body$;
$decoded_content=Base64Decode($content);
WriteFile("<TAG>Targets/Files/FMLA _Extract</TAG>",$decoded_content);
</trans>
But when the multiple attachments are pulled, it creates 1 large file. This large file sometimes shows the first page, but most of the time Adobe is not able to read it. Instead, I would like to have multiple files listed on my target directory.
Thank you in advance for your help!
Target file:
FMLA_Extract
What does your file target look like? (Targets/File/FMLA_Extract). I'm guessing it's configured to append to existing files and you're not changing the file name, so they all get glommed on top of each other.

Alfresco lucene search cannot find folder

I have a folder in document library of a site. I want to find all content of that folder. Running following lucene/alfresco-fts query in Node Browser returns No items found:
PATH:"/app:company_home/st:sites/cm:mysite/cm:documentLibrary/cm:MyFolder/*"
Which is wrong, as I have documents in that folder and running same query for different folder returns proper result. Another strange thing is that I cannot get this folder: following query also returns No items found:
PATH:"/app:company_home/st:sites/cm:mysite/cm:documentLibrary/cm:MyFolder"
Also if I get content of document library then MyFolder is skipped in the results and subfolder is returned:
PATH:"/app:company_home/st:sites/cm:mysite/cm:documentLibrary/*"
Name | Parent
--------------|---------------------
cm:MyFolder2 | /app:company_home/st:sites/cm:mysite/cm:documentLibrary
cm:MySubfolder| /app:company_home/st:sites/cm:mysite/cm:documentLibrary/cm:MyFolder
I have checked the aspects and properties of MyFolder and they are the same as MyFolder2. I do not have any custom behaviours/rules/etc.
How can I make first lucene query work and return content of MyFolder?
Try updating metadata on the folder so Solr re-indexes it. You could also get its db id and then tell solr to re-index it by db id. If it has over 1000 children, a FTS query may fail. - Known issue. Try using a txmd query.
I would suggest you to get the node ref of the folder from folder details page and search in node browser. There you can get the primary path. Please cross verify the path you use to search using lucene or use that primary path to search for the folder in lucene search.
Another possibility is that the locale property(sys:locale) of the folder(MyFolder) will be different from the locale of your browser. Please check whether the locale of MyFolder and the other folders for which result is shown, are same or not. If not that can also be a reason.

How to get all the items contained inside a office365 onedrive

I want to get all the files and folders contained inside a office365 onedrive folder in one rest API call, is there any option to do it?
There isn't a specific API call to retrieve a flat representation of a Drive. You can achieve a similar effect however using the drive's search method.
Simply pass an empty query string and it will return metadata for each file (regardless of it's directory):
https://graph.microsoft.com/v1.0/me/drive/root/search(q='')
Ok, try this search request:
https://graph.microsoft.com/v1.0/me/drive/root/search(q='%2A')
Or:
https://api.onedrive.com:443/v1.0/drives/(driveid)/items/(itemid)/view.search?q=%2A
Where %2A is asterisk, itemid may be a root folder id. Don't forget about pagination.
Or with OneDriveSDK:
_connection.SearchForItemsAsync(odFolder.ItemReference(), "*", ItemRetrievalOptions.Default)
Don't use "expand" query with search query.
This should return all items in current folder recursively - sub-folders, sub-items.