Google Drive API to get folder list using Parent Id - google-api

I am trying to get all folders under a google drive folder using parent folder id
using below api
content.googleapis.com/drive/v3/files/
passing parent id in request body
am able to create files and folders under parent id, but when try to get folder list in parent folder its giving me error as bad request
Note: I am using postman tool

If you want to use a query when listing results, the syntax is '1234567' in parents, not parents=1234567
In your case, the correct syntax would be something like
https://www.googleapis.com/drive/v3/files?q=%2710oCPwjGlp8ArZGP0nk2jnvztniaCRdH4%27%20in%20parents

Related

SonarQube API search issues with componentKeys by directory

In the SonarQube docs it says that componentKeys can be the following:
Comma-separated list of component keys. Retrieve issues associated to a specific list of components (and all its descendants). A component can be a portfolio, project, module, directory or file.
I want to get all the issues from components of a specific directory. I have tried to use the * wildcard like this:
http://localhost:9000/api/issues/search?componentKeys=projectkey:src/testcases/*
or
http://localhost:9000/api/issues/search?componentKeys=src/testcases/*
This doesn't seem to work, how can you search issues by a directory?
You can pass your projectKey name as ComponentKeys and pull all the issues from the project.
http://localhost:9000/api/issues/search?componentKeys=testproject

File ID different from the URL File ID - Google Drive API

I'm trying to access a file in a Google Drive directory but linking to it using the File Id provided by the API it says that i don't have permission. What i saw is that the File Id in the URL is different from the one who returns from the API. Why?
Using the test page of the Google Api it returns a "Not Found" error(404) and not the "No Permissions" error. Anybody knows how to get this ID(same of the url) that links to the file instead of the File's ID
Edit: Found that the File Resource has a property called "webViewLink" is it the link to the file instead of using the ID?
When you are trying the Drive API, you can set using fields property what values you want to return from your call as it is shown in this image:
webViewLink will return you the link that's shown when you open the file in your browser.
id will return you the ID of the file.
I specified some values, but you can see HERE all the values you could use and if you put "*" you will return all of them. Also, I didn't show in the image the id of the file to not share that info.
HERE you can see why you are getting that error. Surely, you don't have enough permitions because you have already checked that it exists for what I understood in your question.

Google Drive api scope and file access (drive vs drive.files)

I have created two refresh tokens for me:
one for
SCOPE = 'https://www.googleapis.com/auth/drive'
and another
SCOPE = 'https://www.googleapis.com/auth/drive.file'
I'm trying to get information about files (using get method)
Some files I can get when using SCOPE drive.files, and some only when using wider scope drive
But I can not figure out what is the reason for that? Files are located in different folders but have one shared root folder.
The difference is that 'drive.file' only gives you permission to files that your app has created or the user has explicitly shared with your app, whereas 'drive' gives your app permission to see the all the files in the user's drive.
See
https://developers.google.com/drive/web/scopes
You should really look into using drive.file, that is where they are trying to push users. I was just fighting with this myself and found that if you use the drive.file scope, you can then subsequently open the file that is chosen using the API for the file type, but only if you set the correct AppID.
See here: https://developers.google.com/picker/docs/#gdata
This allows you to get past the 404 error that you get if you don't set the AppID.

IBM Connections Files CMIS: Unable to find object at path /My Files

I am using DotCMIS with no problem to connect to Alfresco and FileNet.
I registered for an IBM Connections account, added a few files via the web interface, and tried to connect to its CMIS endpoint https://greenhouse.lotus.com/files/basic/cmis/my/servicedoc
GetRepositories on this URL gives one repository, which in turn contain the two folders below:
My Files
My Folders
But when I run GetObjectByPath("/My Files") in the same repository, I get:
DotCMIS.Exceptions.CmisObjectNotFoundException was unhandled
Message=Not Found
Source=DotCMIS
ErrorContent=<?xml version="1.0" encoding="UTF-8"?><lcmis:error xmlns:lcmis="http://www.ibm.com/xmlns/prod/sn/cmis"><lcmis:code>objectNotFound</lcmis:code><lcmis:message>EJPVJ9023E: Unable to find object at path /My Files</lcmis:message><lcmis:userAction></lcmis:userAction></lcmis:error>
What does IBM Connections say Unable to find object at path /My Files despite My Files being a folder at the root of the repository?
The cmis:name property ("My Files", "My Folers") is localized. A non-English user would get different cmis:name property values for these two objects.
To fetch children from these resources, you need to build the path using the cmis:path property returned on each object or construct the path relative to its parent using the cmisra:pathSegment.
For example, the cmis:object for the resource labeled "My Files" in your scenario has the following:
<cmis:propertyString propertyDefinitionId="cmis:path"
localName="cmis_path" displayName="Path" queryName="cmis:path">
<cmis:value>/files</cmis:value>
</cmis:propertyString>
So to actually fetch the user's files, the path to call is the following:
GetObjectByPath("/files")
And to fetch the user's folders, the path to call is the following:
GetObjectByPath("/collections")
The net is to ensure you build paths using the cmisra:pathSegment or the cmis:path property, and not the cmis:name as this may not be valid in all scenarios (i.e. if the repository has same name siblings, etc.).

DocsList findFolder() issue

This is a google spreadsheet script question.
I have a GUI setup in order to search for "SouthWest" and then find a "test" sheet. This is the code I am using.
var file = DocsList.getFolder("SouthWest").find("test");
This works just fine when I run it under my account (as I have this folder and file setup correctly) but when another user is logged into google docs it will attempt to search for this folder/file under the new user instead of the owner of the document. Is there a way to have it just search the DocsList of the owner of the spreadsheet that is currently open? The error that I get under the new user is "Error encountered: Cannot find folder SouthWest." Thanks.
If you always want to access the same file, you can use the getFileById method and address it directly instead of searching every time:
https://developers.google.com/apps-script/class_docslist#getFileById
Of course, you should make sure that all users are allowed to access that file.

Resources