Skip to content

Instantly share code, notes, and snippets.

@zemogle
Created August 4, 2017 08:46
Show Gist options
  • Save zemogle/80bcf2a9bf43ab595f625f8496800826 to your computer and use it in GitHub Desktop.
Save zemogle/80bcf2a9bf43ab595f625f8496800826 to your computer and use it in GitHub Desktop.
LCO observing portal test
function submit_request(){
var target = {
"type": "SIDEREAL",
"name": "M42",
"ra": 83.8220792,
"dec": -5.3911111,
"proper_motion_ra": 1.67,
"proper_motion_dec": -0.3,
"parallax": 0.0,
"coordinate_system": "ICRS",
"equinox": "J2000",
"epoch": 2000.0,
"rot_mode": "VFLOAT",
"rot_angle": 0.0
}
var molecules = [
{
"type": "EXPOSE",
"instrument_name": "0M4-SCICAM-SBIG",
"filter": "rp",
"exposure_time": 30.0,
"exposure_count": 1,
"bin_x": 2,
"bin_y": 2,
"defocus": 0.0,
}
]
var timewindow = {
"start": "2017-08-07 00:00:00",
"end": "2017-08-14 00:00:00"
}
var request = {
"location":{"telescope_class":"0m4"},
"constraints":{"max_airmass":1.6},
"target": target,
"molecules": molecules,
"windows": [timewindow],
"observation_note" : "Serol",
"type":"request"
}
var data = {
"group_id": "sxe_201708_001",
"proposal": "LCOEPO2014B-010",
"ipp_value": 1.05,
"operator": "SINGLE",
"observation_type": "NORMAL",
"requests": [request],
}
console.log(data)
$.ajax({
url: 'https://observe.lco.global/api/userrequests/',
type: 'post',
data: data,
headers: {'Authorization': 'Token <token>'},
dataType: 'json',
success: function(data){
console.log(data);
}
});
}
@Fingel
Copy link

Fingel commented Aug 8, 2017

Line 53 should be: JSON.stringify(data)
Also you need to add contentType: 'application/json' to the options for $.ajax()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment