I have a auth ticket, and have set a link / URI to ContentServer.
- I can get nodes
- I can create folders and categories
- I don't know how to upload a document. See the code below.
What is needed to fix this?
//Create MultiPart Form Data
MultipartFormDataContent mainRequest = new MultipartFormDataContent();
//Setting the Post parameters
Dictionary<string, string> abc = new Dictionary<string, string>();
abc.Add("type", "144");
abc.Add("parent_id", parentId.ToString());
abc.Add("name", "testDocument");
FormUrlEncodedContent form = new FormUrlEncodedContent(abc);
//Setting the Document
byte[] bb = File.ReadAllBytes("c:\\temp\\testWord.docx");
ByteArrayContent file = new ByteArrayContent(bb);
file.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
//Adding preps to FormData
mainRequest.Add(form);
mainRequest.Add(file, "file");
//Call
//500 internal error.
HttpResponseMessage response = _client.PostAsync("nodes", mainRequest).Result;
response.EnsureSuccessStatusCode();