How to retrive work item id from change set programatically using java api

Hello All,
I followed some questions and documents and now I am able to view the change sets programmatically on the console but in order to fetch the work item ID which is associated with the change set I didn't find any direct method.
So if anyone have the logic to fetch the work item id and work item type will helpful.
Thanks in advance
I followed some questions and documents and now I am able to view the change sets programmatically on the console but in order to fetch the work item ID which is associated with the change set I didn't find any direct method.
So if anyone have the logic to fetch the work item id and work item type will helpful.
Thanks in advance
Accepted answer

The change set is related to the work item using a relationship. You have to follow that, get the other end, check and resolve that end and fetch the item. See https://rsjazz.wordpress.com/2012/11/01/restrict-delivery-of-changesets-to-workitem-types-advisordelivery-of-changesets-associated-to-wrong-work-item-types-advisor/ for how that works. Also see https://rsjazz.wordpress.com/2012/09/19/the-rtc-workitem-link-api-linking-workitems-to-other-elements/ and https://rsjazz.wordpress.com/2012/09/20/the-rtc-workitem-server-link-api-linking-to-work-items-and-other-elements/ for more information about the link API and how to get at the remote data.