Merge pull request #5243 from solgenomics/topic/observations_upload_catch_error
[sgn.git] / mason / brapiclient / studies_post.mas
blob129f5789c59991f72c733bd2530124afabb07e09
2 <h3>BrAPI Study POST</h3>
4 <script>
6 jQuery.ajax({
7         type: 'POST',
8         url: 'http://127.0.0.1:3000/brapi/v1/token?username=janedoe&password=secretpw&grant_type=password',
9         success: function(response) {
10                 console.log(response);
11                 var url = jQuery('#brapi_home_url_select').val()+'/brapi/v1/studies?session_token='+response.session_token;
13                 jQuery.ajax({
14                         type: 'POST',
15                         url: url,
16                         beforeSend: function() {
17                                 jQuery('#working_modal').modal("show");
18                         },
19                         data: {
20                                 studyName: "Test_study_01",
21                                 locationDbId: "23",
22                                 studyYears: "2016",
23                                 programDbId: "134",
24                                 optionalInfo: JSON.stringify({
25                                         studyType: "Trial",
26                                         studyObjective: "Test POST Study",
27                                 }),
28                         },
29                         success: function(response) { 
30                                 console.log(response);
31                                 jQuery('#working_modal').modal("hide");
33                         },
34                         error: function(response) { 
35                                 jQuery('#working_modal').modal("hide");
36                                 alert("An error occurred.");
37                         }
38         });
40         }
41 });
44 </script>