0
votes

I'm trying to use the Microsoft Dynamics SOAP request:

XRMServices/2011/Organization.svc/web

with the following request:

<Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">
<request i:type=\"a:retrieveOptionSetRequest\" xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts\">
    <a:Parameters xmlns:b=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">
        <a:KeyValuePairOfstringanyType>
            <b:key>Name</b:key>
            <b:value i:type=\"c:string\" xmlns:c=\"http://www.w3.org/2001/XMLSchema\">new_industry</b:value>
        </a:KeyValuePairOfstringanyType>
    </a:Parameters>
    <a:RequestId i:nil=\"true\" />
</request>
</Execute>

but, being a novice all I get bad is "Bad request"! Any help will be greatfully received!

Thanks

1

1 Answers

0
votes

There is a few issues with the your request. Firstly the request is 'RetrieveOptionSetRequest' not 'retrieveOptionSetRequest' (it will tell you this doesn't exist!)

Secondly there is a missing '\' on your request line

<request i:type=\"a:retrieveOptionSetRequest\" xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts\">

Should be

<request i:type=\"a:RetrieveOptionSetRequest\" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\">

If you fix those two issues then you will find you still won't get the required result. As can be seen at the website mentioned by Pedro Azevedo you need to include the MetadataId and RetrieveAsIfPublished parameters or you won't get a result (the response will make you aware of this). You need to include RequestName in your request.

Your final request should look like this

<Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">
<request i:type=\"a:RetrieveOptionSetRequest\" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\">
    <a:Parameters xmlns:b=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">
        <a:KeyValuePairOfstringanyType>
            <b:key>MetadataId</b:key>
            <b:value i:type=\"c:guid\" xmlns:c=\"http://schemas.microsoft.com/2003/10/Serialization/\">00000000-0000-0000-0000-000000000000</b:value>
        </a:KeyValuePairOfstringanyType>
        <a:KeyValuePairOfstringanyType>
            <b:key>Name</b:key>
            <b:value i:type=\"c:string\" xmlns:c=\"http://www.w3.org/2001/XMLSchema\">new_industry</b:value>
        </a:KeyValuePairOfstringanyType>
        <a:KeyValuePairOfstringanyType>
            <b:key>RetrieveAsIfPublished</b:key>
            <b:value i:type=\"c:boolean\" xmlns:c=\"http://www.w3.org/2001/XMLSchema\">false</b:value>
        </a:KeyValuePairOfstringanyType>
    </a:Parameters>
    <a:RequestId i:nil=\"true\" />
    <a:RequestName>RetrieveOptionSet</a:RequestName>
</request>
</Execute>