2

I am trying to query using search.asmx ex query and query methods using soap api's

I am getting the following err "Data at the root level is invalid. Line 1, position 1."

Please help .

I am following the format:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <QueryEx xmlns="http://microsoft.com/webservices/OfficeServer/QueryService">
      <queryXml>string</queryXml>
    </QueryEx>
  </soap:Body>
</soap:Envelope>

Request:
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><QueryEx xmlns="http://microsoft.com/webservices/OfficeServer/QueryService"><queryXml>OI-415954</queryXml></QueryEx></soap:Body></soap:Envelope>

Response:
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>Data at the root level is invalid. Line 1, position 1.</faultstring><faultactor>site anme/_vti_bin/search.asmx</faultactor><detail><error xmlns="http://microsoft.com/webservices/OfficeServer/QueryService">ERROR_BAD_REQUEST</error><linenumber xmlns="http://microsoft.com/webservices/OfficeServer/QueryService">1</linenumber><lineposition xmlns="http://microsoft.com/webservices/OfficeServer/QueryService">1</lineposition></detail></soap:Fault></soap:Body></soap:Envelope>
1

The query format should be similar as

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <Query
            xmlns="urn:Microsoft.Search">
            <queryXml>
            <![CDATA[<QueryPacket xmlns='urn:Microsoft.Search.Query'>
<Query><SupportedFormats><Format revision='1'> urn:Microsoft.Search.Response.Document:Document
</Format></SupportedFormats><Context><QueryText language='en-US' type='STRING'>OI-415954</QueryText></Context></Query></QueryPacket>]]>                
            </queryXml>
        </Query>
    </soap:Body>
</soap:Envelope>
  • Can u please tell me how to limit it to only items,ot return only items – prajwal rao Oct 1 '18 at 7:36
  • You may create a scope to limit to list item only, and then query based on the scope, the tool archive.codeplex.com/?p=fastforsharepoint would be helpful for you to build the query. – Lee_MSFT Oct 1 '18 at 8:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.