Method for post api call:
string xml = "";
string Type = "", EventName = "", EventPath = "", UserName = "", Password = "";
Type = "POST";
EventName = "PREAPPROVALSUBMISSION";
EventPath = "https://www.devapi.anoudapps.com/api/medical/hospital-service/v3/pre-approval";
UserName = "nova_api";
Password = "nova_api123";
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
var encoding = System.Text.Encoding.GetEncoding("ISO-8859-1");
byte[] headerBytes = encoding.GetBytes(UserName + ":" + Password);
string headerValue = Convert.ToBase64String(headerBytes);
CookieContainer cookies = new CookieContainer();
HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create(EventPath);
webRequest.Credentials = new NetworkCredential(UserName, Password);
webRequest.Method = Type;
webRequest.Headers.Add("company", "009");
webRequest.Headers.Add("Authorization", "Basic " + headerValue);
webRequest.ContentType = "multipart/form-data";
webRequest.CookieContainer = cookies;
webRequest.KeepAlive = true;
webRequest.Accept = "application/json";
//please use below data for post
var formdata = "{{\"policyNo\":\"P2209000174\"}, {\"memberId\":\"MEM21341411\"},
{\"category\":\"001\"},{\"illness\":\"001\"},{\"priority\":\"2\"},
{\"primaryDiagnosis\":\"R93.421\"},{\"medicalRecordNo\":\"0115731\"},{\"serviceType\":\"O\"},
{\"admissionType\":\"M\"},{\"visitDate\":\"19/02/2023\"},{\"doctorLicenseNo\":\"D8622\"}
{\"currency\":\"QAR\"},{\"mobileNo\":\"55849898\"},{\"illnessDetails\":\"follow up after
treatment of UTI\"},{\"treatmentsData\":\"
{\"treatType\":\"O\",\"treatCode\":\"51741\",\"quantity\":\"1\",\"treatDesc\":\"Urine flow
study\",\"estimatedAmount\":\"600.0000\",\"remarks\":\"\"},
{\"treatType\":\"O\",\"treatCode\":\"74183\",\"quantity\":\"1\",\"treatDesc\":\"MRI Abdomen
without and with contrast \",\"estimatedAmount\":\"3450.0000\",\"remarks\":\"\"},
{\"treatType\":\"O\",\"treatCode\":\"99242\",\"quantity\":\"1\",\"treatDesc\":\"Consultation -
Specialist (All)\",\"estimatedAmount\":\"300.0000\",\"remarks\":\"\"}\"}
{\"visitNo\":\"6461204\"},{\"medicalHistory\":\"Diabetes, dyslipidemia\"}}";
string inputJson = (new JavaScriptSerializer()).Serialize(formdata);
using (var streamWriter = new StreamWriter(webRequest.GetRequestStream()))
{
streamWriter.Write(inputJson);
streamWriter.Flush();
streamWriter.Close();
var webResponse = (HttpWebResponse)webRequest.GetResponse();
using (StreamReader streamReader = new StreamReader(webResponse.GetResponseStream()))
{
DataSet dsXml = new DataSet();
xml = streamReader.ReadLine();
StringReader sr = new StringReader(xml);
dsXml.ReadXml(sr);
if (dsXml.Tables[0].Rows.Count > 0)
{
if (common.myStr(dsXml.Tables[0].Rows[0]["messageType"]) != "S")
{
Alert.ShowAjaxMsg("Invalid Qatar Id", Page);
return;
}
}
dsXml.Dispose();
}
}
What I have tried:
Error throw: HTTP Validation: unparsable request content Details:No boundary define for multipart request