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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Loop through a WebApi Result

(0) ShareShare
ReportReport
Posted on by

Anytime, I try to loop the WebAPI(Json result), I always get the first value in the api printed the number of count of the result.

If I have 50 results in the Web Api query the first company(eg. ABC Corp) will be printed 50x. 

Here is a sample code below, I am using to test from https://github.com/davidyack/Xrm.Tools.CRMWebAPI/tree/master/dotnet:

string fetchXml = "<fetch mapping='logical'><entity name='account'><attribute name='accountid'/><attribute name='name'/></entity></fetch>";

var fetchResults = await api .Result.Item2.GetList("accounts", QueryOptions: new CRMGetListOptions() { FetchXml = fetchXml });

foreach (var record in fetchResults.List){
      foreach (var account in record){
         _accountRecord.accountIdNumber = account.Value.ToString();
         _account.Add(_accountRecord);
                             }
                     }

I would like to be able to pint out each company/account name our DynamicsCrmOnline.


Thank you in advance,

*This post is locked for comments

I have the same question (0)

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…

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ZS-27011425-0 Profile Picture

ZS-27011425-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans