0

I execute url from microsoft: like this

And I got the result like:

<SuggestResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Query>state of decay 2</Query>
    <ResultSets>
        <SuggestResults>
            <Source>dcatall-products</Source>
            <FromCache>true</FromCache>
            <Type>product</Type>
            <Suggests>
                <Product>
                    <Curated>false</Curated>
                    <Source>Games</Source>
                    <Title>State of Decay 2</Title>
                    <Url>//www.microsoft.com/en-us/store/p/state-of-decay-2/9nt4x7p8b9nb</Url>
                    <ImageUrl>//store-images.s-microsoft.com/image/apps.30042.14425140369408817.aa13e205-dc3a-4b1f-b9db-3cc6eda9b9ef.94017af1-0966-4275-810b-fe47f11c81d0?w=150&amp;h=150</ImageUrl>
                    <Metas>
                        <Meta>
                            <Key>BigCatalogId</Key>
                            <Value>9NT4X7P8B9NB</Value>
                        </Meta>
                        <Meta>
                            <Key>ProductType</Key>
                            <Value>Game</Value>
                        </Meta>
                        <Meta>
                            <Key>Icon</Key>
                            <Value>//store-images.s-microsoft.com/image/apps.30042.14425140369408817.aa13e205-dc3a-4b1f-b9db-3cc6eda9b9ef.94017af1-0966-4275-810b-fe47f11c81d0</Value>
                        </Meta>
                        <Meta>
                            <Key>ImageHeight</Key>
                            <Value>150</Value>
                        </Meta>
                        <Meta>
                            <Key>ImageWidth</Key>
                            <Value>150</Value>
                        </Meta>
                        <Meta>
                            <Key>ImageType</Key>
                            <Value>Tile</Value>
                        </Meta>
                        <Meta>
                            <Key>AppBgColor</Key>
                            <Value>#ca6929</Value>
                        </Meta>
                    </Metas>
                </Product>
                <Product>
                    <Curated>false</Curated>
                    <Source>Games</Source>
                    <Title>State Of Decay 2: Ultimate Edition</Title>
                    <Url>//www.microsoft.com/en-us/store/p/state-of-decay-2-ultimate-edition/9nsch45hz9hk</Url>
                    <ImageUrl>//store-images.s-microsoft.com/image/apps.16619.14365785075596216.1152921504746356298.788f6ae8-57e0-4a3f-8bda-6c2d5e4d546c?w=150&amp;h=150</ImageUrl>
                    <Metas>
                        <Meta>
                            <Key>BigCatalogId</Key>
                            <Value>9NSCH45HZ9HK</Value>
                        </Meta>
                        <Meta>
                            <Key>ProductType</Key>
                            <Value>Game</Value>
                        </Meta>
                        <Meta>
                            <Key>Icon</Key>
                            <Value>//store-images.s-microsoft.com/image/apps.16619.14365785075596216.1152921504746356298.788f6ae8-57e0-4a3f-8bda-6c2d5e4d546c</Value>
                        </Meta>
                        <Meta>
                            <Key>ImageHeight</Key>
                            <Value>2160</Value>
                        </Meta>
                        <Meta>
                            <Key>ImageWidth</Key>
                            <Value>2160</Value>
                        </Meta>
                        <Meta>
                            <Key>ImageType</Key>
                            <Value>BoxArt</Value>
                        </Meta>
                        <Meta>
                            <Key>AppBgColor</Key>
                            <Value>#FFFFFF</Value>
                        </Meta>
                    </Metas>
                </Product>
                <Product>
                    <Curated>false</Curated>
                    <Source>Devices</Source>
                    <Title>State of Decay 2 for Xbox One</Title>
                    <Url>//www.microsoft.com/en-us/store/p/state-of-decay-2-for-xbox-one/8p2fgp3bf0fc</Url>
                    <ImageUrl>//img-prod-cms-rt-microsoft-com.akamaized.net/cms/api/am/imageFileData/RE1Tc21?ver=3d93&amp;w=272&amp;h=223&amp;o=f&amp;m=6&amp;f=jpg</ImageUrl>
                    <Metas>
                        <Meta>
                            <Key>BigCatalogId</Key>
                            <Value>8P2FGP3BF0FC</Value>
                        </Meta>
                        <Meta>
                            <Key>ProductType</Key>
                            <Value>Devices</Value>
                        </Meta>
                        <Meta>
                            <Key>Icon</Key>
                            <Value>https://img-prod-cms-rt-microsoft-com.akamaized.net/cms/api/am/imageFileData/RE1Tc21?ver=3d93</Value>
                        </Meta>
                        <Meta>
                            <Key>ImageHeight</Key>
                            <Value>1540</Value>
                        </Meta>
                        <Meta>
                            <Key>ImageWidth</Key>
                            <Value>1189</Value>
                        </Meta>
                        <Meta>
                            <Key>ImageType</Key>
                            <Value>tile</Value>
                        </Meta>
                    </Metas>
                </Product>
            </Suggests>
        </SuggestResults>
        <SuggestResults>
            <Source>microsoft-terms</Source>
            <FromCache>false</FromCache>
            <Type>term</Type>
            <Suggests>
                <Term>
                    <Curated>false</Curated>
                    <Txt>state of decay year one survival edition</Txt>
                </Term>
                <Term>
                    <Curated>false</Curated>
                    <Txt>state of decay year one survival edition for xbox one</Txt>
                </Term>
                <Term>
                    <Curated>false</Curated>
                    <Txt>state of decay for xbox 360 download code</Txt>
                </Term>
            </Suggests>
        </SuggestResults>
    </ResultSets>
    <ErrorSets>
        <SuggestErrorSet>
            <Source>iris-products</Source>
            <Message>Code: 2040. Message: Demand source returns error (Name: GN_ps, Error: No eligible content.).</Message>
        </SuggestErrorSet>
    </ErrorSets>
</SuggestResponse>

I have pasted the result xml (in Visual studio I chose Edit -> Paste special -> Paste XML as classes) ...

When deserialize with Newtonsoft Json

var data = JsonConvert.DeserializeObject<MsQueryXmlDetailResponse.SuggestResponse>(response);

I got:

Unexpected character encountered while parsing value: <. Path '', line 0, position 0.'

I tried also

var data = JsonConvert.DeserializeObject<MsQueryXmlDetailResponse>(response);

But same thing...

Snake Eyes
  • 16,287
  • 34
  • 113
  • 221

0 Answers0