2

I'm am trying to re-implement a class which reads from Azure CosmosDB using the Microsoft.Azure.Documents.Client.DocumentClient so that I can make use of the continuation token functionality.

However, when I try to retrieve data I get the following error:

Error converting value \"NWE2OGY5MzYzMmY0OGIlM2Ix\" to type 'MongoDB.Bson.ObjectId'

To begin with this isn't on of our id values, but I tried to implement an ObjectIdConverter as detailed here, but then started getting this error:

String should contain only hexadecimal digits.

As the value it's trying to use doesn't actuall correspond to an entry id.

I then put in a JsonConverter for the actual object I'm trying to de-serialize to and and loaded the json into a JObject so I could see what I'm dealing with.

The structure doesn't match what I expect or what I see in Robo 3T:

{{
  "$t": 3,
  "$v": {
    "_id": {
      "$t": 7,
      "$v": "ù62ô;Üöã±"
    },
    "Channel": {
      "$t": 2,
      "$v": "channel"
    },
    "TopicRoutingKey": {
      "$t": 18,
      "$v": 123,
      "$s": "123"
    },
    "SequenceNumber": {
      "$t": 18,
      "$v": 1,
      "$s": "1"
    },
    "CorrelationId": {
      "$t": 5,
      "$v": "00000006\u0003Ù\bÜ\"²f@\u085L+SæÝ"
    },
    "Message": {
      "$t": 2,
      "$v": "2gIUCJSAOBGMCv1eTLCAHKJ2QjhUx/iCtT5t0YsfS10JIsIJSAOQ=="
    }
  },
  "id": "NWE2OGY5MzmRjZjZlM2Ix",
  "_rid": "znt6AKAAAAAAAAA==",
  "_self": "dbs/znt6AA==/colls/znt6AK0j8AU=/docs/znt6AKAAAAAAAAA==/",
  "_etag": "\"3b02af0b-0000-0000-0000-5a68f9370000\"",
  "_attachments": "attachments/",
  "_ts": 1516828983
}}

I'm assuming these are type / value tuples and I can see the data I want is in the root $v: but I can't figure out how to de-serialize this (short of replicating the data structure myself and then de-serializing to it, then converting to my actual data structure which seems like it shouldn't be necessary).

Can anyone tell me what is going on here?

RagtimeWilly
  • 5,265
  • 3
  • 25
  • 41

0 Answers0