Hello. I've been looking into the CS 10.5 WS using C#. I began using Postman to get a feel for the API's. I'm able to authenticate and get and create nodes just fine. The problem I'm having is with uploading a file in C#. In Postman, I'm able to upload a file without an issue. I"ve copied the RESTSHARP code as suggested by Postman and updated the parameters to fit the dynamic file being loaded. The file appears in my node (folder) but there are no contents. It shows 0 Kb. Right now i'm only working with Excel files so the content-type is hard coded.
The response I receive is :
StatusCode: OK, Content-Type: application/json; charset=UTF-8, Content-Length: 13)
Here is the code i'm using.
server is the path (http://usrd12z4t1009/)
EXE is OTCS/cs.exe/
Ticket is my authentication ticket
RestClient client = new RestClient(String.Format("{0}{1}api/v1/nodes", server, EXE)); RestRequest request = new RestRequest(Method.POST); request.AddHeader("Postman-Token", "08a94d81-b303-43ed-b7c2-ad58e64a43c1"); request.AddHeader("cache-control", "no-cache"); request.AddHeader("Content-Type", "multipart/form-data"); request.AddHeader("otcsticket", ticket); request.AddHeader("content-type", "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW"); request.AddParameter("multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW", String.Format("------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"type\"\r\n\r\n{0}\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"parent_id\"\r\n\r\n{1}\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"file\"; filename=\"{2}\"\r\nContent-Type: {5}\r\n\r\n\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n{3}\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"description\"\r\n\r\n{4}\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--", type, parent_id, file, name, description, @application/vnd.openxmlformats-officedocument.spreadsheetml.sheet), ParameterType.RequestBody); var response = client.Execute(request);
Thank you for any help