Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Error sending SOAP reqest containing OptionSetValue

Posted on by Microsoft Employee

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

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Error sending SOAP reqest containing OptionSetValue

    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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Error sending SOAP reqest containing OptionSetValue

    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 ''. '.

  • Verified answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Error sending SOAP reqest containing OptionSetValue

    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>


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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans