web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Queryexpression not returing results

(0) ShareShare
ReportReport
Posted on by 75

I am attempting to make a console application to retrieve results using the Dynamics CRM SDK and C# but I can't seem to get any results from my queries. I can see that I am connected to the CRM instance, but any QueryExpression I try to make seems to come back with nothing, even if I set it with no filter.  I have also tried with fetchxml, no results returned. I am getting the below error.

Exception thrown: 'System.ServiceModel.FaultException`1' in Microsoft.Xrm.Sdk.dll
An unhandled exception of type 'System.ServiceModel.FaultException`1' occurred in Microsoft.Xrm.Sdk.dll
Invalid XML.

The account which I am using is admin account. Any suggestions would be helpful. Thanks in advance!!

8168.screen.PNG1050.Capture.PNG

I have the same question (0)
  • Suggested answer
    Guido Preite Profile Picture
    54,086 Moderator on at

    checking if the userid value is not an empty is kind of useless, if you have connection problems you will get an exception before getting to that line.

    Let's assume only the QueryExpression of your second screenshot (the fetchxml of your first screenshot is clearly unformatted but it should be ok) if you remove the condition you will get all the contacts in the system (up to 5000), if you still get an error (and the userid has value) then post your full code, because that code you posted should work

  • Verified answer
    Bipin D365 Profile Picture
    28,983 Moderator on at

    Hi,

    There seems to be an issue with fetch xml.

    I would recommend to use below tool to format your fetchxml to use in C# console.

    www.ashishvishwakarma.com/.../

    If found helpful, Please mark my answer verified.

  • Jayaa E Profile Picture
    75 on at

    Thanks a lot Bipin. As you said, the issue was in fetchxml.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 70 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 33 Most Valuable Professional

#3
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans