title: InsertInlineImage or ReplaceImage URI
body: <p>I'm writing a WinForms application. I created a Google Doc template file that contains placeholders like {{name}} for various text elements. I can successfully make a copy of this document and use the BatchUpdateDocumentRequest to modify them just fine.</p>
  
  <p>However, I also have an embedded image in the document. I can obtain the objectId for this image just fine. I either want to replace this image with another or remove it from my template and then append my new image to the end of the document. In both cases, the InsertInlineImage or ReplaceImage classes require a URI of the image to insert or replace with. This is where I have an issue.</p>
  
  <p>The image itself has been captured from a control on the WinForms. Its actually a chart. I've saved the image in PNG format since I know that is one of the formats supported by Google drive/docs. I figured in order to use it in the batch update, I would need to upload it first, so I did and got its file id and webcontentlink back in the response.</p>
  
  <p>I'm not locked into any particular way of doing this. I originally tried creating an HTML file, uploading but then it would strip the image from it, so became useless, so I switched gears to using a Google Doc as my template and just try to replace elements in it instead. This went well until I got to the image. </p>
  
  <p>Essentially no matter what I try to specify as the URI, it says the file in not in a supported format. </p>
  
  <p>As far as I can tell, Google expects the URI to actually end in .png or be a real link versus a download URL you'd get from Google Drive. </p>
  
  <p>Here is an example of the code I'm using to attempt to replace the image. The strImageObjectId is the objectId of the Embedded Object image in the template document copy that I want to replace. The Uri is what Google needs to pull the new image from. I'm happy to pull it from my local computer or Google Drive if only I could get it to accept it somehow.</p>
  
  <pre><code>BatchUpdateDocumentRequest batchUpdateRequest = new BatchUpdateDocumentRequest {
      Requests = new List&lt;Google.Apis.Docs.v1.Data.Request&gt;()
  };
  request = new Google.Apis.Docs.v1.Data.Request {
      ReplaceImage = new ReplaceImageRequest() {
          ImageObjectId = strImageObjectId,
          Uri = strChartWebContentLink
      }
  };
  batchUpdateRequest.Requests.Add(request);
  DocumentsResource.BatchUpdateRequest updateRequest = 
      sDocsService.Documents.BatchUpdate(batchUpdateRequest, strCopyFileId);
  BatchUpdateDocumentResponse updateResponse = updateRequest.Execute();
  </code></pre>
  
  <p>I'm happy to use whatever method will get me to a point where I an end up with a Google Doc on Google Drive that was based on a template in which I can replace various text elements, but most importantly add/replace an image.</p>
  
  <p>Thanks so much for the advice.</p>