Discussions
POST to panel: Unable to cast object of type
From the documentation: https://developer.imis.com/reference/postpanelsourcedata-1
I am trying to post to my panel, I took the "$type" from either the documentation or from the GET request returned from my panel. I have tried a few different variations and still get a similar error:
System.InvalidCastException: Unable to cast object of type 'Asi.Soa.Core.DataContracts.GenericExecuteRequest' to type 'Asi.Soa.Core.DataContracts.GenericEntityData'.
at Asi.Services.Core.EntityServiceToCommonServiceAdapter1.Add(Object dataContract) at Asi.Services.Core.EntityServiceToCommonServiceAdapter
1.AddAsync(Object dataContract)
at Castle.Proxies.Invocations.ICommonServiceAsync_AddAsync.InvokeMethodOnTarget()
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at Asi.Shared.Aspects.AsyncInterceptor.<>cDisplayClass2_0`1.b0()
at Asi.Shared.Aspects.CacheAspect.d5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Asi.Services.Core.Interceptors.CommonSecurityAspect.d1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Asi.Shared.Aspects.PerformanceAspect.d3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Asi.ImisService.Controllers.CommonServiceController.d14.MoveNext()
Next my request:
const settings = {
async: true,
crossDomain: true,
url: 'https://.ca/api/Comments',
method: 'POST',
headers: {
accept: 'application/json',
'content-type': 'application/json',
"RequestVerificationToken": document.getElementById("__RequestVerificationToken").value
},
processData: false,
data: JSON.stringify({
"$type": "Asi.Soa.Core.DataContracts.GenericExecuteRequest, Asi.Contracts",
"Properties":
{
"$type": "Asi.Soa.Core.DataContracts.GenericEntityData, Asi.Contracts",
"$values":
[{
"$type": "Asi.Soa.Core.DataContracts.IdentityData, Asi.Contracts",
"Name": "ID",
"Value": "79887"
},
{
"$type": "Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts",
"Name": "DateTime",
"Value": "2012-06-12T16:16:29.013"
},
{
"$type": "Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts",
"Name": "Body",
"Value": "The addendum to the article is that the Supreme Court of Canada has granted leave to appeal the Federal Court of Appeal’s."
},
{
"$type": "Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts",
"Name": "Link",
"Value": "www.google.ca/en/newsletters/canadian_tax_focus/2012/2/120508"
},
{
"$type": "Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts",
"Name": "SubmittedID",
"Value": "79887"
},
{
"$type": "Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts",
"Name": "User",
"Value": "Adriana Escalante"
}]
}
})}
jQuery.ajax(settings).done(function (response) {
console.log(response);
});
Thank you in advance for your help.
Regards,
Adriana E