web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Error sending SOAP reqest containing OptionSetValue

(0) ShareShare
ReportReport
Posted on by

Hi,

I am trying to insert a new lead containing data set as type OptionSet Value, however I am getting the following error message:

The formatter threw an exception while trying to deserialize the message:
There was an error while trying to deserialize parameter schemas.microsoft.com/.../Services:request.
The InnerException message was 'Error in line 1 position xxxx.
Element 'schemas.datacontract.org/.../System.Collections.Generic:value' contains data from a type that maps to the name 'schemas.microsoft.com/.../Services:OptionSetValue'.
The deserializer has no knowledge of any type that maps to this name.
Consider changing the implementation of the ResolveName method on your DataContractResolver to return a non-null value for name 'OptionSetValue' and namespace 'schemas.microsoft.com/.../Services'.'.'. Please see InnerException for more details.


The request is being sent using PHP and the soap body is shown below. If the field containing the option value is removed the lead is successfully created.

<s:Body>
<Execute xmlns="schemas.microsoft.com/.../Services" xmlns:i="www.w3.org/.../XMLSchema-instance">
<request i:type="a:CreateRequest" xmlns:a="schemas.microsoft.com/.../Contracts">
<a:Parameters xmlns:b="schemas.datacontract.org/.../System.Collections.Generic">
<a:KeyValuePairOfstringanyType>
<b:key>Target</b:key>
<b:value i:type="a:Entity">
<a:Attributes>
<a:KeyValuePairOfstringanyType>
<b:key>firstname</b:key>
<b:value i:type="c:string" xmlns:c="www.w3.org/.../XMLSchema">Lead Name</b:value>
</a:KeyValuePairOfstringanyType>
<a:KeyValuePairOfstringanyType>
<b:key>lastname</b:key>
<b:value i:type="c:string" xmlns:c="www.w3.org/.../XMLSchema">Last name</b:value>
</a:KeyValuePairOfstringanyType>
<a:KeyValuePairOfstringanyType>
<b:key>emailaddress1</b:key>
<b:value i:type="c:string" xmlns:c="www.w3.org/.../XMLSchema">lead@email.co.uk</b:value>
</a:KeyValuePairOfstringanyType>
<a:KeyValuePairOfstringanyType>
<b:key>telephone1</b:key>
<b:value i:type="c:string" xmlns:c="www.w3.org/.../XMLSchema">011111111111</b:value>
</a:KeyValuePairOfstringanyType>
<a:KeyValuePairOfstringanyType>
<b:key>description</b:key>
<b:value i:type="c:string" xmlns:c="www.w3.org/.../XMLSchema">Message</b:value>
</a:KeyValuePairOfstringanyType>
<a:KeyValuePairOfstringanyType>
<b:key>subject</b:key>
<b:value i:type="c:string" xmlns:c="www.w3.org/.../XMLSchema">Website Enquiry</b:value>
</a:KeyValuePairOfstringanyType>
<a:KeyValuePairOfstringanyType>
<b:key>d:at_enquiry</b:key>
<b:value i:type="OptionSetValue">115500001</b:value>
</a:KeyValuePairOfstringanyType>
</a:Attributes><a:EntityState i:nil="true" />
<a:FormattedValues>
<a:KeyValuePairOfstringstring>
<b:key>d:at_enquiry</b:key>
<b:value>Website</b:value>
</a:KeyValuePairOfstringstring>
</a:FormattedValues>
<a:Id>00000000-0000-0000-0000-000000000000</a:Id>
<a:LogicalName>lead</a:LogicalName><a:RelatedEntities />
</b:value>
</a:KeyValuePairOfstringanyType>
</a:Parameters><a:RequestId i:nil="true" />
<a:RequestName>Create</a:RequestName>
</request>
</Execute>
</s:Body>

*This post is locked for comments

I have the same question (0)
  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Try to use following for optionset:

    <a:KeyValuePairOfstringanyType>
    	<b:key>at_enquiry</b:key>
    	<b:value i:type="a:OptionSetValue">115500001</b:value>
    </a:KeyValuePairOfstringanyType>


  • Community Member Profile Picture
    on at

    Thank you for your suggestion. I've tried that however I'm now getting the message:  

    There was an error while trying to deserialize parameter schemas.microsoft.com/.../Services:request. The InnerException message was 'Error in line 1 position 12883. Expecting state 'Element'.. Encountered 'Text' with name '', namespace ''. '.

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    It's really hard to gues what's wrong with your SOAP without an access to your full code and environment. What should really help you is SoapLogger - www.powerobjects.com/.../microsoft-dynamics-crm-soap-logger-a-tool-that-can-greatly-simplify-writing-http-requests

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans