• Robert Taylor 81
  • NEWBIE
  • 0 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
Why does the following fail to deserialize?
Blob b = Blob.valueOf('test1');
ContentVersion cv = new ContentVersion(VersionData=b);
String cvString = JSON.serialize(cv);
System.debug('ContentVersion serialized: ' + cvString);
ContentVersion cvd = (ContentVersion)JSON.deserialize(cvString, ContentVersion.class);

Output
15:15:38.4 (5368573)|USER_DEBUG|[248]|DEBUG|ContentVersion serialized: {"attributes":{"type":"ContentVersion"},"VersionData":{"asByteArray":"dGVzdDE=","inputStream":{},"length":5,"maxToKeep":6}}
15:15:38.4 (10114668)|FATAL_ERROR|System.JSONException: Cannot deserialize instance of base64 from START_OBJECT value { or request may be missing a required field at [line:1, column:40]