Hi Manoj.
You actually raise up a good point. There is a difference between Iterations and Milestones but it's not very well explained (in my opinion) in the documentation. They are both time boxes but they are not the same.
Iteration belongs to a project. You create it under a project, when you view it you can see the project it belongs to. Therefore, in your code you can set a workspace and set a project and then query for an iteration. Rally will look for iterations in the context of the workspace and project you're asking for.
Milestones, however, do not belong to a project. They belong to a workspace. Milestone may include any or all of the projects of that workspace but it doesn't 'belong' to the projects. Milestones are similar to projects themselves. The projects in-fact are part of the milestone. Therefore, from your code's perspective, you can not set up a context for a milestone that will be a workspace and a project. A project can not set a context for a milestone. The context for the milestone is the workspace alone. That's why if you set a project , it's ignored and you're getting the milestones defined for your workspace.
In my earlier reply, what I tried to convey is that if you're interested to know if a certain project is part of a milestone (again, a milestone is not part of a project) then you can query for the milestone, then look at the Projects collection field (see that screen shot earlier) to find if a specific project is part of that milestone.
You can learn more on Milestones here:
Create and Manage Milestones | CA Agile Central Help
But , as said, I do feel as well this documentation isn't very clear on that difference.
I'd also like to share with you the object model so that you actually see the difference.
Both an Iteration and Milestone belong with a Workspace. However,
Iteration - You can see in the WSAPI docs that the iteration is associated with one project.
Milestone - You can see more than just one project is associated with the milestone. Also, from the endpoint construction you can learn that the projects are 'underneath' the milestone.
I hope this makes it a bit more clear. Please let us know if it does.
Thanks,
Sagi