How to get ProjectId using Upsource API
Hi,
I am trying to use Upsource REST API. I am wondering how to get {ProjectID} for my current project? Which RPC method to use if I had only directory cloned from git repository.
Please sign in to leave a comment.
HI Alexey,
Sorry for the delayed response.
Probably you should start with getAllProjects method? By the way what are trying to accomplish with Upsource API?
I`m trying to create small VIM plugin for upsource. Here is general use case: I have cloned project from our git repository(which is already have upsource review for example) I need to get all comments for particular file in this project. But all RPC calls in Upsource API have projectID as a parameter. I wonder how can I get this ID, if I just cloned this project from my git repository? All I ave is git upstream URL. Is there any way to get Project ID from that URL or any other way? Thank you in advance.
Ok, thank for the clarification.
You might first get all projects with mentioned above getAllProjects and then use loadPorject method to get vcs settings (link to your git repo).
Ok. I call loadProject and get the following
curl -s --user ponkin:**** -X POST -d '{"projectId" : "shiny-new-project" }' https://upsource.company.ru/\~rpc/loadProject
response
{"error":{"code":101, "message":"User Aleksey Ponkin doesn't have admin access to project shiny-new-project"}}
Do I need admin privileges to get VCS settings?
How does it work in IntellijIDEA?
Hi Alexey,
Yes, you should have project admin permissions to get VCS settings.
What exactly are looking for in IDEA?
I don't get it. How can I bind my project (simply cloned from git repository) with Upsource projectId? What if I do not have admin rights?
When I use IntelliJIDEA there is simple plugin for upsource which automatically shows for example all file comments and so on.
Upsource plugin works through a service which has all necessary permissions... In your case, when you try to get vcs settings under a regular Upsource user, you should have enough permissions to accomplish it.
So it turns out that there is no way for 3-rd party applications to use Upsource REST API, without having admin user privileges? Is it possible to implement something like getProjectIdByVcsLink or something like that in future releases?
Is there any other options to link arbitrary project( which is already under the upsurge code review) with its projectId in Upsource?
It's rather sensitive information, so we don't want to give everybody permissions by default to observe VCS links. And of course 3-rd party applications should have some permissions in Upsource to access the data.. For some data project admin permissions are required.
Will it be an issue for you to get project admin permissions?
Yes.
Now I need to bind git project with Upsource projectId manually from VIM editor. It is obviously not convinient.
Can I submit some kind of feature request to Upsource REST API?
Yes, sure, you might file feature request here - https://youtrack.jetbrains.com/issues/up