1245
Views
14
Comments
Cannot deserialize the current JSON object
Question
Anybody has een idea how I can solve this?

Trying to get data from a rest webservice. Response added in text file attatched. 
Doesn't matter what I try I always get below issues. 

Parsing '4': Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'ssApplication1.CcMagextension+RESTGetProductsResponse[]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
Path '4', line 1, position 5.
Repsonse.txt
2012-03-16 12-21-09
João Rosado
Staff
Hi Sander,

Did you try turning the logging details on to see if thats exactly the response that you are getting?

Here is how to turn the logging on:
- In ServiceCenter go to your eSpace and select the Integrations tab.
- click on the name of your REST integration.
- There you should be able to see the configurations for it, including an option to turn detailed logging.
- Execute your action again to make the call
- In Service Cente go to Monitoring -> Consumed Web Services
- There should be a line on the log for your call with a "Detail" or "Error" link in the side. With the logging on that will show you the complete request/response of the service.

From what you posted it looks like you are getting a completly different response from what you posted.

Regards,
João Rosado


2020-05-27 11-47-28
Brajesh Mehra
Did you find any solution on that?

I am too facing similar error.
2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
Brajesh,

Did you follow João's advice? If so, did you verify if what is logged has the same structure as what you have specified in the consume REST?
2020-05-27 11-47-28
Brajesh Mehra
Hi Kilian,

I did enable debugging mode as described above. 

Still I am not sure, why that error is. 

I am getting the attached error in servicecenter, and Also attaching the JSON request I am sending.

Can you please let me know why that error is occuring. 

Error Message:

Request:

Thank you very much! 
2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
Hi Brajesh,

Can you do the following:
1) Copy/paste here the full Response JSON (as above only a part is shown);
2) Copy/paste the debug logging of the call that causes the error

2020-05-27 11-47-28
Brajesh Mehra
Thank you very much for quick reply!

here is the JSON:

[
      {
      "EncounterTypes":       [
                  {
            "Value": "I",
            "Description": "Inpatient"
         },
                  {
            "Value": "O",
            "Description": "Outpatient"
         },
                  {
            "Value": "E",
            "Description": "Emergency"
         }
      ],
      "EventTypes":       [
                  {
            "Value": "ADT_A01",
            "Description": "Admission"
         },
                  {
            "Value": "ADT_A03",
            "Description": "Discharge"
         },
                  {
            "Value": "ADT_A06",
            "Description": "Inpatient Transfer"
         },
                  {
            "Value": "ADT_A50",
            "Description": "In/out Patient Transfer"
         }
      ],
      "Facilities":       [
                  {
            "Value": "LIJH",
            "Description": "LIJ Hospical"
         },
                  {
            "Value": "NSUH",
            "Description": "North Shore University Hospital"
         },
                  {
            "Value": "SIUH",
            "Description": "Staten Island University Hospital"
         },
                  {
            "Value": "LXHH",
            "Description": "LXHH"
         },
                  {
            "Value": "FHSH",
            "Description": "FHSH"
         },
                  {
            "Value": "FRKH",
            "Description": "FRKH"
         },
                  {
            "Value": "GCVH",
            "Description": "GCVH"
         },
                  {
            "Value": "HNTH",
            "Description": "HNTH"
         },
                  {
            "Value": "PLVH",
            "Description": "PLVH"
         },
                  {
            "Value": "STHS",
            "Description": "STHS"
         }
      ],
      "Cohort": "CareConnect",
      "Subscription": "CareConnectNotificationFwSP",
      "Rule": "CCRulePrgBased1",
      "Description": "CareConnect Filter Rule PrgBased1",
      "Enabled": "1"
   },
      {
      "EncounterTypes": [      {
         "Value": "E",
         "Description": "Emergency"
      }],
      "EventTypes": [      {
         "Value": "ADT_A04",
         "Description": "Emergency"
      }],
      "Facilities":       [
                  {
            "Value": "LIJH",
            "Description": "LIJ Hospical"
         },
                  {
            "Value": "NSUH",
            "Description": "North Shore University Hospital"
         },
                  {
            "Value": "SIUH",
            "Description": "Staten Island University Hospital"
         },
                  {
            "Value": "LXHH",
            "Description": "LXHH"
         },
                  {
            "Value": "FHSH",
            "Description": "FHSH"
         },
                  {
            "Value": "FRKH",
            "Description": "FRKH"
         },
                  {
            "Value": "GCVH",
            "Description": "GCVH"
         },
                  {
            "Value": "HNTH",
            "Description": "HNTH"
         },
                  {
            "Value": "PLVH",
            "Description": "PLVH"
         },
                  {
            "Value": "STHS",
            "Description": "STHS"
         }
      ],
      "Cohort": "CareConnect",
      "Subscription": "CareConnectNotificationFwSP",
      "Rule": "CCRulePrgBased2",
      "Description": "CareConnect Filter Rule PrgBased2",
      "Enabled": "1"
   }
]
2020-05-27 11-47-28
Brajesh Mehra
Here is the debugging message from Servicecenter

Message:
Failed to parse response of the method 'PutFilterRules' of the 'FilterRules' REST API:
Parsing 'RequestTime': Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'ssNotificationUI.CcFilterRules+RESTAllFilterRules[]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
Path 'RequestTime', line 1, position 15.
Environment Information eSpaceVer: 69 (Id=4479, PubId=5521, CompiledWith=9.0.1.35)
RequestUrl: https://sykdhieospsap1v/NotificationUI/FilterRules.aspx?_ts=1449693978770 (Method: POST)
AppDomain: /LM/W3SVC/1/ROOT/NotificationUI-172-130941532642323729
FilePath: C:\...\PS\running\NotificationUI\FilterRules.aspx
Locale: en-US
DateFormat: yyyy-MM-dd
PID: 4324 ('w3wp', Started='12/3/2015 1:05:43 AM', Priv=690Mb, Virt=18293Mb)
TID: 419
Thread Name: 
.NET: 4.0.30319.34209
Stack:
Failed to parse response of the method 'PutFilterRules' of the 'FilterRules' REST API:
Parsing 'RequestTime': Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'ssNotificationUI.CcFilterRules+RESTAllFilterRules[]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
Path 'RequestTime', line 1, position 15.

   at ssNotificationUI.CcFilterRules.ActionPutFilterRules(HeContext heContext, ICcFilterRulesCallbacks _callbacks, String inParamCohort, String inParamSubscription, RLAllFilterRulesList inParamRequest, RLAllFilterRulesList& outParamResponse)
   at ssNotificationUI.Flows.FlowMainFlow.ScrnFilterRules.CommandSave(HeContext heContext)

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
Hi Brajesh,

You didn't show the debugging information, but the error information. What you need to do is the following:
1) Go to the eSpace in Service Center
2) Go to the Integrations tab
3) Search for "Consumed REST APIs" and click the name in the Name column; you'll go to a new page
4) Set Logging Level to Full, press Apply

Then do again whatever triggers the error. Next, still in Service Center, click Monitoring, then Integrations. You'll find a REST (Consume) that corresponds with your REST call. Click "Details" (last column). There you'll find the full HTTP Trace. Please copy/paste that.
2020-05-27 11-47-28
Brajesh Mehra
I did the same:


Error in real application:



HTTP Trace:

[{"EncounterTypes":[{"Value":"I","Description":"Inpatient"},{"Value":"O","Description":"Outpatient"},{"Value":"E","Description":"Emergency"}],"EventTypes":[{"Value":"ADT_A01","Description":"Admission"},{"Value":"ADT_A03","Description":"Discharge"},{"Value":"ADT_A06","Description":"Inpatient Transfer"},{"Value":"ADT_A07","Description":"Outpatient Transfer"},{"Value":"ADT_A50","Description":"In/out Patient Transfer"}],"Facilities":[{"Value":"LIJH","Description":"LIJ Hospical"},{"Value":"NSUH","Description":"North Shore University Hospital"},{"Value":"SIUH","Description":"Staten Island University Hospital"},{"Value":"LXHH","Description":"LXHH"},{"Value":"FHSH","Description":"FHSH"},{"Value":"FRKH","Description":"FRKH"},{"Value":"GCVH","Description":"GCVH"},{"Value":"HNTH","Description":"HNTH"},{"Value":"PLVH","Description":"PLVH"},{"Value":"STHS","Description":"STHS"}],"Cohort":"RestWSTesting","Subscription":"RestWSTestingSP","Rule":"RWSRule1","Description":"RestWSTesting Filter Rule 1","Enabled":"1"},{"EncounterTypes":[{"Value":"I","Description":"Inpatient"},{"Value":"O","Description":"Outpatient"}],"EventTypes":[{"Value":"ADT_A04","Description":"Emergency"}],"Facilities":[{"Value":"LIJH","Description":"LIJ Hospical"},{"Value":"NSUH","Description":"North Shore University Hospital"},{"Value":"SIUH","Description":"Staten Island University Hospital"},{"Value":"LXHH","Description":"LXHH"},{"Value":"FHSH","Description":"FHSH"},{"Value":"FRKH","Description":"FRKH"},{"Value":"GCVH","Description":"GCVH"},{"Value":"HNTH","Description":"HNTH"},{"Value":"PLVH","Description":
2020-05-27 11-47-28
Brajesh Mehra
Here is the full downloaded file. 
FilterRules.PutFilterRules.trace.txt
2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
Mmm, is that the full visible HTTP trace? It seems there's something missing, unfortunately.

However, the error message complains about parsing "RequestTime". I can't find it in the Response definition however.
2020-05-27 11-47-28
Brajesh Mehra
I attached a full downloaded file. did you get it?
2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
Ah, now I see :). The response from the REST service is two fields: RequestTime and Status. However, you've put the request JSON in the Response field as well :). If you replace it by {"RequestTime":"2015-12-10 14:52:56","Status":"OK"}, it should be ok.
2020-05-27 11-47-28
Brajesh Mehra
Yes. It's worked. Thank you very much!
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.