I am calling a SalesForce API added as a WebReference in my Console Test application.
one of the parameter that it requires is of type object. To be precise, following is my code:
SFObject sfObject = new SFObject
{
type = "User",
Item = new { ExternalId = 2}
};
I am passing the code above where API is expecting the Item's type to be object().
When I make the final call, I am seeing following error:
{"<>f__AnonymousType0`1[System.Int32] cannot be serialized
Below is definition of SFObject as my "Add web reference" downloaded it.
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.6.81.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:sfobject.sfapi.successfactors.com")]
public partial class SFObject {
private object itemField;
private string typeField;
private System.Xml.XmlElement[] anyField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("businessKeys", typeof(BusinessKeys))]
[System.Xml.Serialization.XmlElementAttribute("id", typeof(string))]
public object Item {
get {
return this.itemField;
}
set {
this.itemField = value;
}
}
/// <remarks/>
public string type {
get {
return this.typeField;
}
set {
this.typeField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAnyElementAttribute()]
public System.Xml.XmlElement[] Any {
get {
return this.anyField;
}
set {
this.anyField = value;
}
}
}
I searched around and seems like there is some problem with WCF serialization but I am not using WCf here. Is there any way that I can get around this problem?