简体   繁体   中英

CRM dynamics 2011 XML missing request

I am facing a problem with my XML request, which is part of the web to CRM dynamics 2011 in order to create leads.

The code that i'm stuck in at the moment is as follows:

            <s:Body>
                <Create xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services">
                <entity xmlns:b="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
                    <b:Attributes xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
                        <b:KeyValuePairOfstringanyType>
                            <c:key>name</c:key>
                            <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">Name Test 1</c:value>
                            <c:key>E-mail</c:key>
                            <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">test@test.com</c:value>
                        </b:KeyValuePairOfstringanyType>
                    </b:Attributes>
                    <b:EntityState i:nil="true"/>
                    <b:FormattedValues xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic"/>
                    <b:Id>00000000-0000-0000-0000-000000000000</b:Id>
                    <b:LogicalName>account</b:LogicalName>
                    <b:RelatedEntities xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic"/>
                </entity>
                </Create>
            </s:Body>

The name is already available from within the code that I found, I tried to add the Email attribute (even Address) but nothing in the CRM other than the name, what exactly is the error in the code? how should it be fixed?

Any help is appreciated and thank you everyone in advance.

I believe you need to use the logical names of the attributes instead of the display name (emailaddress1 instead of E-mail). Also I believe you need to have a KeyValuePair node for each attribute you want to send since it is an array of attributes you are sending. Try this out instead:

<b:KeyValuePairOfstringanyType>
    <c:key>name</c:key>
    <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">Name Test 1</c:value>
</b:KeyValuePairOfstringanyType>
<b:KeyValuePairOfstringanyType>
    <c:key>emailaddress1</c:key>
    <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">test@test.com</c:value>
</b:KeyValuePairOfstringanyType>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM