Is there any way to upload the Html page into custom page of CA Agile rally through code instead of manually doing it, through Web apis.
There is currently no fully supported way to do this via the API. There are private endpoints in the product which could technically be used for this but there is no guarantee their paths or arguments will not change.
If you'd like to explore doing this you can inspect the network tab in your browser when you create a new page (/slm/wt/new.sp) and when you add a custom html app to it (/slm/dashboard/addpanel.sp) and when you edit the settings with your code (/slm/dashboard/changepanelsettings.sp)