AddImageToCell in smartsheet-csharp-sdk always throws an exception

Hello developers,

I am currently working on integrating Smartsheet API into my application and have encountered an issue related to image uploads using the Smartsheet SDK.

The specific error message I'm encountering is: "Only images can be uploaded. Please use a file of type jpg, gif, or png." I have already ensured that the content type is set to "image/jpeg," and the file being uploaded is indeed a valid JPEG image.


Here is the code:


public void AddImageToCell(long rowId, string columnName, string altText, string imageURL)
{
  string tempFilePath = DownloadImage(imageURL);
  try
  {
    long columnId = (long)GetColumnIdByName(columnName);
    string contentType = "image/jpg";
    RowColumnResources rowColumnResources = _smartsheetClient.SheetResources.RowResources.CellResources;
    rowColumnResources.AddImageToCell(_sheetID, rowId, columnId, tempFilePath, contentType, true, altText);
  }
  catch(Exception ex)
  {
    throw ex;
  }
  finally
  {
    if (File.Exists(tempFilePath))
    {
      File.Delete(tempFilePath);
    }
  }
}

---------------------------------------------------------------------------------------------

    private string DownloadImage(string imageUrl)
    {
      string tempFileName = "temp_image.jpg";
      using (var client = new WebClient())
      {
        client.DownloadFile(imageUrl, tempFileName);
      }
      return tempFileName;
    }


It was working in the older versions but in the latest one it is not.

Answers