Hi,
I want to create a dataset using Excel Sheet through Rest API
When I am sending Post request from Application to Upload File then getting JSON String in response,
After Parsing JSON taking the Virtual location of the file and Sending Another Request to Preview the File.When Sending Request to Preview the File then getting Exception like 400 bad request
I have attached the content and URL that I am using for rest call
File Upload
url:https://localhost:9047/home/%40Test/upload_start/test_Xlsheet/?extension=xlsx
Code
Content: string boundary = “----WebKitFormBoundary” + DateTime.Now.Ticks.ToString(“x”);
byte[] boundarybytes = Encoding.ASCII.GetBytes("\r\n–" + boundary + “\r\n”);
HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(url);
wr.Headers.Add(“Authorization”, dremioAccessToken);
wr.ContentType = “multipart/form-data; boundary=” + boundary;
wr.Method = “POST”;
byte[] trailer = Encoding.ASCII.GetBytes("–" + boundary + “\r\n”);
rs.Write(trailer, 0, trailer.Length);
string headerTemplate = “Content-Disposition: form-data; name=“file”;
filename=”+fileName.Split(’.’)[0]+"\r\nContent-Type: application/vnd.openxmlformats-
officedocument.spreadsheetml.sheet\r\n\r\n";
byte[] headerbytes = Encoding.UTF8.GetBytes(headerTemplate);
rs.Write(headerbytes, 0, headerbytes.Length);
trailer = Encoding.ASCII.GetBytes("\r\n–" + boundary + “\r\n”);
rs.Write(trailer, 0, trailer.Length);
headerTemplate = “Content-Disposition: form-data; name=“fileConfig”\r\n\r\n{“name”:”" + fileName.Split(’.’)[0] + “”}";
headerbytes = Encoding.UTF8.GetBytes(headerTemplate);
rs.Write(headerbytes, 0, headerbytes.Length);
trailer = Encoding.ASCII.GetBytes("\r\n–" + boundary + “\r\n”);
rs.Write(trailer, 0, trailer.Length);
headerTemplate = “Content-Disposition: form-data; name=“fileName”\r\n\r\n” +
fileName.Split(’.’)[0];
headerbytes = Encoding.UTF8.GetBytes(headerTemplate);
rs.Write(headerbytes, 0, headerbytes.Length);
trailer = Encoding.ASCII.GetBytes("\r\n–" + boundary + “–”);
rs.Write(trailer, 0, trailer.Length);
Response
location:adl://mysource.azuredatalakestore.net/dremio/uploads/_staging.dremio-master-0.dremio-master.default.svc.cluster.local/@Test/test_Xlsheet/Book1_xlsx-37346a52-56ef-4333-9012-e69667507350
File Preview URL
https://localhost:9047/apiv2/home/%40Test/upload_finish/test_Xlsheet/Book1
body content:
{“extractHeader”: false,
“hasMergedCells”: false,
“location”: “adl://mysource.azuredatalakestore.net/dremio/uploads/_staging.dremio-coordinator-5fp6n/@Test/test_Xlsheet/Book1_xlsx-37346a52-56ef-4333-9012-e69667507350”,
“type”: “Excel”}