How to use Azure ML API with Ruby on Rails -
i using code url , api key every time error of 405 or 400. there proper way implement azure ml api in rails.
the code below :-
data = {
"inputs" => { "input1" => { "columnnames" => @a, "values" => [ @writer ] }, }, "globalparameters" => { } } body = data.to_json puts "adssssssssssssssssssssssssssssss#{body}" url = "https://ussouthcentral.services.azureml.net/workspaces/5aecd8f887e64999a9c854d724e5d45b/services/5f350fa1b48647ce95c5279eee2170d0/execute?api-version=2.0&details=true" api_key = 'wgmmqgylo4tttv+otjrrwksbzmcjxgfy7ejb1b1vxyu5hmeerx/tyt6xysmwskceznkkbgwvavt0wsessjuorq==' # replace api key web service headers = {'content-type' => 'application/json', 'authorization' => ('bearer '+ api_key)} url = uri.parse(url) req = net::http::get.new(url.request_uri,headers) http = net::http.new(url.host, url.port) res = http.request(req) {"inputs":{"input1":{"columnnames":["encounter_id","patient_nbr","fname","lname","email","type","race","gender","birth date","birth year","age","age min","age max","weight","admission_type_id","discharge_disposition_id","admission_source_id","time_in_hospital","payer_code","medical_specialty","num_lab_procedures","num_procedures","num_medications","number_outpatient","number_emergency","number_inpatient","number_diagnoses","max_glu_serum","a1cresult","metformin","repaglinide","nateglinide","chlorpropamide","glimepiride","acetohexamide","glipizide","glyburide","tolbutamide","pioglitazone","rosiglitazone","acarbose","miglitol","troglitazone","tolazamide","examide","citoglipton","insulin","glyburide-metformin","glipizide-metformin","glimepiride-pioglitazone","metformin-rosiglitazone","metformin-pioglitazone","change","diabetesmed","readmitted"],"values":[[[{"$oid":"56b1ab886e75720ba23b5400"},"","rana","warhurst",null,"patient","caucasian","male","2012-10-23","",3,"","","","",null,null,null,"",null,"","","","","","",null,"","no","no"]]]}},"globalparameters":{}}
after research, atlast got answer, can done unirest gem easily
url = "url ml" api = "ml api key" headers = "same above" response = unirest.post url, headers: headers, parameters: body response.code response.headers response.body response.raw_body
the result values stored in response.body
Comments
Post a Comment