Bhubaneswar, Odisha, India
+91-8328865778
support@softchief.com

Use FetchXML in WEB API using Power Automate with HTTP action for Dataverse and Dynamics 365

Use FetchXML in WEB API using Power Automate with HTTP action for Dataverse and Dynamics 365

In Business scenarios we sometimes require to use Fetch XML to read data from Dataverse or Dynamics 365 CE. In this post you will come to know how to use Fetch XML in HTTP action of Power Automate and call Dataverse or Dynamics 365 Web API end point.

Follow below steps.

Step 1: Prepare Fetch XML

First build the fetch XML and download and keep it ready. The below sample fetch XML shows reading accounts from dynamics 365 CE.

<fetch mapping="logical">  
 <entity name="account">  
  <attribute name="accountid" />  
  <attribute name="name" />  
  <attribute name="industrycode" />  
 <order attribute="name" />  
 </entity>  
</fetch>

Step 2: Encode the Fetch XML for URL

Go to https://meyerweb.com/eric/tools/dencoder/ and paste the fetch XML inside the textbox and click encode. This will generate the encoded URL version of the fetch XML.

After encode it will generate the below code.

%3Cfetch%20mapping%3D%22logical%22%3E%20%20%0A%20%3Centity%20name%3D%22account%22%3E%20%20%0A%20%20%3Cattribute%20name%3D%22accountid%22%20%2F%3E%20%20%0A%20%20%3Cattribute%20name%3D%22name%22%20%2F%3E%20%20%0A%20%20%3Cattribute%20name%3D%22industrycode%22%20%2F%3E%20%20%0A%20%3Corder%20attribute%3D%22name%22%20%2F%3E%20%20%0A%20%3C%2Fentity%3E%20%20%0A%3C%2Ffetch%3E

Copy the encoded string and keep it.

Step 3: In Power Automate use the string in fetchXml query.

Open power automate add an instant trigger. You can add any trigger of your choice. Add new action called HTTP and use Get method and in URI, give the environment URL with entity set. Add headers as given below.

  • Content-Type : application/json
  • OData-MaxVersion : 4.0
  • OData-Version : 4.0
  • Prefer: odata.include-annotations=”*”

In the Query section add the encoded fetch Xml.

Now if you run the Power Automate it will show result.

When you click to download link from Output section it will give the result.

You can parse the JSON result and use it in next steps.

hope this helps

Follow my blog for more trending topics on Dynamics 365, Azure, C#, Power Portals and Power Platform. For training, Courses and consulting, call to us at +91 832 886 5778 I am working more for community to share skills in Dynamics 365 and Power Platform. Please support me by subscribing my YouTube Channel. My YouTube Channel link is this : https://www.youtube.com/user/sppmaestro

You can enroll now !We are giving 30% discount on our Internship Program

Don’t miss the chance to participate in the upcoming Internship Program which will be done using Microsoft Dot Net Web Development Full Stack Technology. The new batch will be starting from May 20, 2024.  We will have most experienced trainers for you to successfully complete the internship with live project experience.

Why to choose Our Internship Program?

Industry-Relevant Projects
Tailored Assignments: We offer projects that align with your academic background and career aspirations.
Real-World Challenges: Tackle industry-specific problems and contribute to meaningful projects that make a difference.

Professional Mentorship
Guidance from Experts: Benefit from one-on-one mentorship from seasoned professionals in your field.
Career Development Workshops: Participate in workshops that focus on resume building, interview skills, and career planning.

Networking Opportunities
Connect with Industry Leaders: Build relationships with professionals and expand your professional network.
Peer Interaction: Collaborate with fellow interns and exchange ideas, fostering a supportive and collaborative environment.

Skill Enhancement
Hands-On Experience: Gain practical skills and learn new technologies through project-based learning.
Soft Skills Development: Enhance communication, teamwork, and problem-solving skills essential for career success.

Free Demo Class Available