Hi Experts,
I am also getting similar error. we are sending message to azure service bus queue using azure aware plugins and then processing it using azure function.
Howvere on deserialisig the recieving below error
"error deserializing the object of type Microsoft.Xrm.Sdk.RemoteExecutionContext. Encountered invalid character ' '."
below is my json. can you point out what could be wrong with this json, i have tried validating jason with various and json is validating green with no error.
{
"BusinessUnitId": "18b282e2-166e-e711-8122-70106fa12a51",
"CorrelationId": "c03aa288-99cd-4bfa-9532-18f07ec77004",
"Depth": 1,
"InitiatingUserAzureActiveDirectoryObjectId": "00000000-0000-0000-0000-000000000000",
"InitiatingUserId": "2699416d-c5d1-e811-a9cb-000d3ad1c507",
"InputParameters": [
{
"key": "Target",
"value": {
"__type": "Entity:http://schemas.microsoft.com/xrm/2011/Contracts",
"Attributes": [
{
"key": "address1_line1",
"value": "87A"
},
{
"key": "address1_city",
"value": "Glenholm st"
},
{
"key": "address2_city",
"value": "Glenholm st"
},
{
"key": "jjr_abn_not_applicable",
"value": true
},
{
"key": "address2_stateorprovince",
"value": "qld"
},
{
"key": "address2_postalcode",
"value": "4053"
},
{
"key": "jjr_departmentid",
"value": {
"__type": "EntityReference:http://schemas.microsoft.com/xrm/2011/Contracts",
"Id": "131224da-2ae2-e811-a9d4-000d3ad1c8a7",
"KeyAttributes": [],
"LogicalName": "jjr_department",
"Name": null,
"RowVersion": null
}
},
{
"key": "address1_postalcode",
"value": "4053"
},
{
"key": "address2_line1",
"value": "87A"
},
{
"key": "address1_stateorprovince",
"value": "qld"
},
{
"key": "modifiedonbehalfby",
"value": null
},
{
"key": "jjr_businessclassification",
"value": {
"__type": "EntityReference:schemas.microsoft.com/.../Contracts",
"Id": "219a1b08-09cd-e811-a9d4-000d3ad1ce4e",
"KeyAttributes": [],
"LogicalName": "jjr_businessclassification",
"Name": null,
"RowVersion": null
}
},
{
"key": "accountid",
"value": "1ed0399f-bb69-eb11-a812-000d3acb6edf"
},
{
"key": "jjr_organisationalunitid",
"value": {
"__type": "EntityReference:schemas.microsoft.com/.../Contracts",
"Id": "6d3ac5b3-5321-ea11-a812-000d3ad0a866",
"KeyAttributes": [],
"LogicalName": "msdyn_organizationalunit",
"Name": null,
"RowVersion": null
}
},
{
"key": "address2_composite",
"value": "87A Glenholm st qld 4053 Australia"
},
{
"key": "jjr_company_name",
"value": "Taco"
},
{
"key": "modifiedon",
"value": "/Date(1612754075000)/"
},
{
"key": "jjr_customerpartytype",
"value": {
"__type": "OptionSetValue:schemas.microsoft.com/.../Contracts",
"Value": 965680001
}
},
{
"key": "modifiedby",
"value": {
"__type": "EntityReference:schemas.microsoft.com/.../Contracts",
"Id": "2699416d-c5d1-e811-a9cb-000d3ad1c507",
"KeyAttributes": [],
"LogicalName": "systemuser",
"Name": null,
"RowVersion": null
}
},
{
"key": "address1_composite",
"value": "87A Glenholm st qld 4053 Australia"
},
{
"key": "address2_country",
"value": "Australia"
},
{
"key": "address1_country",
"value": "Australia"
},
{
"key": "jjr_termsofpayment",
"value": {
"__type": "EntityReference:schemas.microsoft.com/.../Contracts",
"Id": "2f27cc65-b761-eb11-a812-000d3a6a449d",
"KeyAttributes": [],
"LogicalName": "msdyn_paymentterm",
"Name": null,
"RowVersion": null
}
},
{
"key": "jjr_integrationstate",
"value": {
"__type": "OptionSetValue:schemas.microsoft.com/.../Contracts",
"Value": 965680001
}
},
{
"key": "address1_latitude",
"value": -27.407623
},
{
"key": "address1_longitude",
"value": 152.9728049
}
],
"EntityState": null,
"FormattedValues": [],
"Id": "1ed0399f-bb69-eb11-a812-000d3acb6edf",
"KeyAttributes": [],
"LogicalName": "account",
"RelatedEntities": [],
"RowVersion": "62982747"
}
}
],
"IsExecutingOffline": false,
"IsInTransaction": false,
"IsOfflinePlayback": false,
"IsolationMode": 1,
"MessageName": "Update",
"Mode": 1,
"OperationCreatedOn": "/Date(1612754076000+0000)/",
"OperationId": "dbe7f1c4-bb69-eb11-a812-000d3acb6edf",
"OrganizationId": "8cbb6fcd-fc9a-4654-b215-200c0dc56bbc",
"OrganizationName": "jjdev",
"OutputParameters": [],
"OwningExtension": {
"Id": "861fd4e0-9906-ea11-a811-000d3ad1c24a",
"KeyAttributes": [],
"LogicalName": "sdkmessageprocessingstep",
"Name": null,
"RowVersion": null
},
"ParentContext": {
"BusinessUnitId": "18b282e2-166e-e711-8122-70106fa12a51",
"CorrelationId": "c03aa288-99cd-4bfa-9532-18f07ec77004",
"Depth": 1,
"InitiatingUserAzureActiveDirectoryObjectId": "00000000-0000-0000-0000-000000000000",
"InitiatingUserId": "2699416d-c5d1-e811-a9cb-000d3ad1c507",
"InputParameters": [
{
"key": "Target",
"value": {
"__type": "Entity:http://schemas.microsoft.com/xrm/2011/Contracts",
"Attributes": [
{
"key": "address1_stateorprovince",
"value": "qld"
},
{
"key": "address1_country",
"value": "Australia"
},
{
"key": "address1_postalcode",
"value": "4053"
},
{
"key": "address1_city",
"value": "Glenholm st"
},
{
"key": "address1_line1",
"value": "87A"
},
{
"key": "address2_stateorprovince",
"value": "qld"
},
{
"key": "address2_country",
"value": "Australia"
},
{
"key": "address2_postalcode",
"value": "4053"
},
{
"key": "address2_city",
"value": "Glenholm st"
},
{
"key": "jjr_company_name",
"value": "Taco"
},
{
"key": "address2_line1",
"value": "87A"
},
{
"key": "jjr_customerpartytype",
"value": {
"__type": "OptionSetValue:http://schemas.microsoft.com/xrm/2011/Contracts",
"Value": 965680001
}
},
{
"key": "jjr_abn_not_applicable",
"value": true
},
{
"key": "jjr_businessclassification",
"value": {
"__type": "EntityReference:http://schemas.microsoft.com/xrm/2011/Contracts",
"Id": "219a1b08-09cd-e811-a9d4-000d3ad1ce4e",
"KeyAttributes": [],
"LogicalName": "jjr_businessclassification",
"Name": null,
"RowVersion": null
}
},
{
"key": "jjr_departmentid",
"value": {
"__type": "EntityReference:schemas.microsoft.com/.../Contracts",
"Id": "131224da-2ae2-e811-a9d4-000d3ad1c8a7",
"KeyAttributes": [],
"LogicalName": "jjr_department",
"Name": null,
"RowVersion": null
}
},
{
"key": "jjr_organisationalunitid",
"value": {
"__type": "EntityReference:schemas.microsoft.com/.../Contracts",
"Id": "6d3ac5b3-5321-ea11-a812-000d3ad0a866",
"KeyAttributes": [],
"LogicalName": "msdyn_organizationalunit",
"Name": null,
"RowVersion": null
}
},
{
"key": "jjr_termsofpayment",
"value": {
"__type": "EntityReference:schemas.microsoft.com/.../Contracts",
"Id": "2f27cc65-b761-eb11-a812-000d3a6a449d",
"KeyAttributes": [],
"LogicalName": "msdyn_paymentterm",
"Name": null,
"RowVersion": null
}
},
{
"key": "accountid",
"value": "1ed0399f-bb69-eb11-a812-000d3acb6edf"
},
{
"key": "address1_composite",
"value": "87A Glenholm st qld 4053 Australia"
},
{
"key": "address2_composite",
"value": "87A Glenholm st qld 4053 Australia"
}
],
"EntityState": null,
"FormattedValues": [],
"Id": "1ed0399f-bb69-eb11-a812-000d3acb6edf",
"KeyAttributes": [],
"LogicalName": "account",
"RelatedEntities": [],
"RowVersion": null
}
},
{
"key": "SuppressDuplicateDetection",
"value": false
}
],
"IsExecutingOffline": false,
"IsInTransaction": false,
"IsOfflinePlayback": false,
"IsolationMode": 1,
"MessageName": "Update",
"Mode": 1,
"OperationCreatedOn": "/Date(1612754076000+0000)/",
"OperationId": "dbe7f1c4-bb69-eb11-a812-000d3acb6edf",
"OrganizationId": "8cbb6fcd-fc9a-4654-b215-200c0dc56bbc",
"OrganizationName": "jjdev",
"OutputParameters": [],
"OwningExtension": {
"Id": "861fd4e0-9906-ea11-a811-000d3ad1c24a",
"KeyAttributes": [],
"LogicalName": "sdkmessageprocessingstep",
"Name": null,
"RowVersion": null
},
"ParentContext": null,
"PostEntityImages": [],
"PreEntityImages": [],
"PrimaryEntityId": "1ed0399f-bb69-eb11-a812-000d3acb6edf",
"PrimaryEntityName": "account",
"RequestId": "b1003cfa-a7c5-43d0-aa99-b6aa32d808ea",
"SecondaryEntityName": "none",
"SharedVariables": [
{
"key": "IsAutoTransact",
"value": true
},
{
"key": "ChangedEntityTypes",
"value": [
{
"__type": "KeyValuePairOfstringstring:#System.Collections.Generic",
"key": "account",
"value": "Update"
}
]
}
],
"Stage": 30,
"UserAzureActiveDirectoryObjectId": "00000000-0000-0000-0000-000000000000",
"UserId": "2699416d-c5d1-e811-a9cb-000d3ad1c507"
},
"PostEntityImages": [
{
"key": "PostImage",
"value": {
"Attributes": [
{
"key": "jjr_integrationstate",
"value": {
"__type": "OptionSetValue:http://schemas.microsoft.com/xrm/2011/Contracts",
"Value": 965680001
}
}
],
"EntityState": null,
"FormattedValues": [
{
"key": "jjr_integrationstate",
"value": "Integrated"
}
],
"Id": "1ed0399f-bb69-eb11-a812-000d3acb6edf",
"KeyAttributes": [],
"LogicalName": "account",
"RelatedEntities": [],
"RowVersion": null
}
},
{
"key": "AsynchronousStepPrimaryName",
"value": {
"Attributes": [
{
"key": "name",
"value": "tr1 - 05054365"
},
{
"key": "accountid",
"value": "1ed0399f-bb69-eb11-a812-000d3acb6edf"
}
],
"EntityState": null,
"FormattedValues": [],
"Id": "1ed0399f-bb69-eb11-a812-000d3acb6edf",
"KeyAttributes": [],
"LogicalName": "account",
"RelatedEntities": [],
"RowVersion": null
}
}
],
"PreEntityImages": [],
"PrimaryEntityId": "1ed0399f-bb69-eb11-a812-000d3acb6edf",
"PrimaryEntityName": "account",
"RequestId": "b1003cfa-a7c5-43d0-aa99-b6aa32d808ea",
"SecondaryEntityName": "none",
"SharedVariables": [
{
"key": "IsAutoTransact",
"value": true
}
],
"Stage": 40,
"UserAzureActiveDirectoryObjectId": "00000000-0000-0000-0000-000000000000",
"UserId": "2699416d-c5d1-e811-a9cb-000d3ad1c507"
}
After formatting the json , i am using below code to deserialize it.
//create an instance of generic type object
RemoteContextType obj = Activator.CreateInstance<RemoteContextType>();
MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(jsonString));
System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(obj.GetType());
obj = (RemoteContextType)serializer.ReadObject(ms);
ms.Close();
return obj;