title: AWS CloudSearch cannot upload documents
body: <p>I am new to AWS and CloudSearch. I have written a very simple app which is to upload docx document (already use cs-import-document to convert to JSON format) to my seach domain.</p>
  
  <p>Code is very straightforward as this:</p>
  
  <pre><code>using (var searchdomainclient = new AmazonCloudSearchDomainClient("http://search-xxxxx-xysjxyuxjxjxyxj.ap-southeast-2.cloudsearch.amazonaws.com"))
  {
  
      // Test to upload doc                            
  
      var uploaddocrequest = new UploadDocumentsRequest()
      {
          FilePath = @"c:\temp\testsearch.sdf",  //docx to JSON already
          ContentType =  ContentType.ApplicationJson
  
      };
      var uploadresult = searchdomainclient.UploadDocuments(uploaddocrequest);
  
     }
  </code></pre>
  
  <p>However the exception I got is: "Root element is missing."</p>
  
  <p>Here is the JSON stuff in the sdf file I want to upload:</p>
  
  <pre><code>[{
      "type": "add",
      "id": "c:_temp_testsearch.docx",
      "fields": {
          "template": "Normal.dotm",
          "application_name": "Microsoft Office Word",
          "paragraph_count": "1",
          "resourcename": "testsearch.docx",
          "date": "2014-07-28T23:52:00Z",
          "xmptpg_npages": "1",
          "page_count": "1",
          "publisher": "",
          "creator": "John Smith",
          "creation_date": "2014-07-28T23:52:00Z",
          "content": "Test5",
          "author": "John Smith",
          "last_modified": "2014-07-29T04:22:00Z",
          "revision_number": "3",
          "line_count": "1",
          "application_version": "15.0000",
          "last_author": "John Smith",
          "character_count": "5",
          "character_count_with_spaces": "5",
          "content_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
      }
  }]
  </code></pre>
  
  <p>So what's wrong with my approach?</p>
  
  <p>Thanks heaps!</p>
  
  <p>P.S. I can manually upload docx doc to that search doamin and use C# code to apply search.</p>
  
  <p><br/><br/><br/></p>
  
  <p><strong>============= Update 2014-08-04 ===================</strong></p>
  
  <p>I am not sure whether it is related to this or not. In the stack trace I found it tries to parse as XML file rather than JSON. But from my code I already set ContentType = JASON, but it seems no effect.</p>
  
  <pre><code>at System.Xml.XmlTextReaderImpl.ThrowWithoutLineInfo(String res)
  at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
  at Amazon.Runtime.Internal.Transform.XmlUnmarshallerContext.Read()
  at Amazon.Runtime.Internal.Transform.ErrorResponseUnmarshaller.Unmarshall(XmlUnmarshallerContext context)
  at Amazon.Runtime.Internal.Transform.JsonErrorResponseUnmarshaller.Unmarshall(JsonUnmarshallerContext context)
  at Amazon.CloudSearchDomain.Model.Internal.MarshallTransformations.UploadDocumentsResponseUnmarshaller.UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
  at Amazon.Runtime.Internal.Transform.JsonResponseUnmarshaller.UnmarshallException(UnmarshallerContext input, Exception innerException, HttpStatusCode statusCode)
  at Amazon.Runtime.AmazonWebServiceClient.HandleHttpWebErrorResponse(AsyncResult asyncResult, WebException we)
  at Amazon.Runtime.AmazonWebServiceClient.getResponseCallback(IAsyncResult result)
  at Amazon.Runtime.AmazonWebServiceClient.endOperation[T](IAsyncResult result)
  at Amazon.CloudSearchDomain.AmazonCloudSearchDomainClient.EndUploadDocuments(IAsyncResult asyncResult)
  at Amazon.CloudSearchDomain.AmazonCloudSearchDomainClient.UploadDocuments(UploadDocumentsRequest request)
  
  
  at Amazon.CloudSearchDomain.Model.Internal.MarshallTransformations.UploadDocumentsResponseUnmarshaller.UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
  </code></pre>