1

I have Rest Service API, the Contract is

        [OperationContract]
        [WebInvoke(
                    Method = "POST",
                    RequestFormat = WebMessageFormat.Json,
                    ResponseFormat = WebMessageFormat.Json,
                    UriTemplate = "/CreateCustomActivity?token={authToken}"
                   )]
        ProcessStatus CreateCustomActivity(string authToken, ProspectActivityCompound activity);

ProspectActivityCompound, dataobject, has a property ActivityFields of datatype

Dictionary<string,string>

This is my requestData

{
    "RelatedProspectId": "2cd12345-1130-11e6-be13-06c7eb5c1234",
    "ActivityEvent": 156,
    "ActivityNote": "asdasdasd",
    "ActivityDate": "/Date(1468394160000)/",
    "ActivityDateTime": "2016-07-13 19:16:00",
    "Score": 9,
    "ActivityFields": {
        "Custom_1": "1234",
        "Custom_2": "asdf",
        "Custom_3": "dfg",
        "Custom_4": "qwe",
    }
}

I know that I can use this to get the data in dictionary.

"ActivityFields": [
          {"Key":"Custom_1", "Value":"1234"},
          {"Key":"Custom_2", "Value":"fgh"},
          {"Key":"Custom_3", "Value":"wer"},
          {"Key":"Custom_4", "Value":"sdfs"}
        ]

I want ActivityFields to come as Key Value pair, but right now its coming as null. The JSON format should be the same, so can anyone give me a method to receive this JSON as Key Value pair.

Mainak
  • 469
  • 3
  • 9
  • 33
Rathore25
  • 46
  • 8
  • Have you tried anything ? – Mainak Jul 13 '16 at 11:10
  • Why not just let json be json? If its that important why not just map the activity fields yourself? – Paul Swetz Jul 13 '16 at 13:37
  • @NewBeeee - How does this differ from the [question for which you offered a bounty](https://stackoverflow.com/questions/8372076/post-json-dictionary-without-key-value-text)? – dbc Jul 13 '16 at 22:00

0 Answers0