Open emirkmo opened 2 years ago
It should actually be possible to modify a target using the exact same API endpoint as for adding a target. Only thing is that you have to add the targetid
to the POST request. Only problem is that you have to add all the information about the target. I.e. you have to provide the full dict. It should be easy to make the Python API pull down the current target information, modify what needs to be modified in the dict, and post it back to the web-API.
I did try this but it returns with the error that target already exists. Are you sure? I tried pulling a random target, modifying only the host, and passing in the targetid. But it's possible I did something wrong.
It should work... What is the exact error message that you get?
Currently, editing the target is possible via the website. The endpoint is /target_save.php
It takes a referrer with some targetid: https://flows.phys.au.dk/target_edit.php?target=114
It also requires cookie and a sessionID to be set, so a logged in client. It would be great if this endpoint was also available via making a POST request to api/target.php?target=114 or something like api/target_save.php?target=114, with the data containing the updated target info. Obviously, the targetid/name should not be updatable, but everything else should be. So that it can be used from within the API without having to make a logged-in client and spoof headers etc.
just for reference, these are the fields (minus targetid/targetname). {'target_name': '2020wtp', 'targetid': 114, 'ra': 124.99880293333, 'decl': 7.79367375, 'catalog_downloaded': True, 'discovery_mag': 19.22, 'inserted': '2020-10-26 09:52:06.485412', 'redshift': 0.07, 'redshift_error': None, 'discovery_date': '2020-10-13 11:25:26.4', 'project': 'ztf-ia', 'host_galaxy': 'api_edited', 'ztf_id': 'ZTF20aciugdl', 'target_status': 'target', 'sntype': 'Ia'}
@rhandberg Could you add this endpoint, and also, could you please provide a list of API endpoints to me as well, so that I have access to them?
Currently, these are the known ones: https://github.com/SNflows/tendrils/blob/da578e1eb56b9e75b3e0fd09d9de52fb13748994/tendrils/utils/urls.py#L13-L26