After two days of debugging, I finally discovered the problem…
The key I was assigning to the object started with a period i.e. ..\images\ABC.jpg
, and this caused the error to occur.
I wish the API provides more meaningful and relevant error message, alas, I hope this will help someone else out there!