title: Passing a Memory Stream from one API to another API
body: <p>I am trying to export some data to excel and store that excel in AWS S3. Our current architecture is like, </p>
  
  <ol>
  <li><p>we get data from database and manipulate it as per our needs. This is done is one API call.</p></li>
  <li><p>We need to pass that data as stream to another API ( specifically designed to interact with AWS S3)</p></li>
  <li><p>Store that stream as Excel file in AWS S3.</p></li>
  </ol>
  
  <p>So far what i have achieved is :</p>
  
  <p>I am able to get data from database and convert it to memory stream. I have written another API to receive this stream.  But couldn't manage to get to pass memory stream from one API to another API.</p>
  
  <p>1st API :</p>
  
  <pre><code>    public async Task&lt;ICollection&lt;UserDTO&gt;&gt; ExportUsers(Guid groupId, HttpRequestMessage request)
      {
  
         var ms = // get's memory stream out of data received from database.
  
            var client = new HttpClient
                               {
                                 BaseAddress = new Uri("http://localhost:58025/")
                               };
                      client.DefaultRequestHeaders.Accept.Clear();
                      client.DefaultRequestHeaders.Accept.Add(
                      new MediaTypeWithQualityHeaderValue("application/bson"));
  
        MediaTypeFormatter bsonFormatter = new BsonMediaTypeFormatter(); 
      //Not sure about BsonMediaTypeFormmater. Juz gave it a try
  
         var response = await  client.PostAsync("http://localhost:58025/Resource/Memory", ms, bsonFormatter);
      }
  </code></pre>
  
  <p>2nd API :</p>
  
  <pre><code>   [HttpPost]
     [Route("Resource/Memory", Name = "UploadMemory")]
     public async Task&lt;IHttpActionResult&gt; UploadMemoryFile(MemoryStream memory)
     {
         // Not reaching until here
     }
  </code></pre>
  
  <p>Any help is highly appreciated!!</p>