How to find the KC ID with application ID?

Certified Associate Developer

We have two drop downs, first one with all the applications list and second one need to fetch the folder names in the KC of the application selected in first drop down.

We need to find the KC ID with the application ID.

Can anyone help how to approach. 

  Discussion posts and replies are publicly visible