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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

How to retrieve knowledge base articles and its attachments to Power Pages?

(1) ShareShare
ReportReport
Posted on by 593
Hi,
     I have been working on the retrieving knowledge base article along with its attachments. I can be able to fetch the knowledge article content, but I could not be able to fetch its attachments. I have used fetch xml to accomplish this.
 
    For fetching attachments, I have tried to fetch the attachments of knowledge article from annotations table by filtering the objecttypecode eq 'knowledgearticle'. I need to get the base64 content of the attachment so that i can add that as a downloadable file in the portal. The filter will be like below.

https://<orgnamexyz123>.crm.dynamics.com/api/data/v9.2/annotations?$filter=objecttypecode eq 'knowledgearticle'
 
But I couldn't get results, and it returns an empty array. Are there any configurations behind this to fetch the attachment value from the D365 CRM Web API.

Any help or suggestions or other workaround on this would be much appreciated.
 
 
 
Thanks,
Tamilarasu Arunachalam
I have the same question (0)
  • Suggested answer
    Muhammad Affan Profile Picture
    4,624 Moderator on at
    Hi There,

    Refer to these links: 
    https://learn.microsoft.com/en-us/dynamics365/customer-service/administer/set-up-knowledge-management-embedded-knowledge-search#update-knowledge-article-attachments-for-portal

    https://community.dynamics.com/forums/thread/details/?threadid=c66cee9f-a99b-4ebd-be11-6e4959d9c4c9


    Finally, once your issue is resolved and my suggested answer has helped, please do not forget to click Yes under "Did this answer your question?" to close this thread.

    Thanks
    Affan
    Follow my channel related to Dynamics 365:  https://www.youtube.com/@AffansDynamicsJourney
     
     
  • Suggested answer
    Sachin Jadhav Profile Picture
    157 on at
    Hi,
     
    • Attachments added on Knowledge article(knowledgearticle) are stored in entity msdyn_kbattachment 
    • The relationship between knowledgearticle and msdyn_kbattachment is M:M (msdyn_msdyn_kbattachment_knowledgearticle) 
    • The actual file content that is the base 64 file itself is then stored in fileattachment table with objecttypecode and objectid pointing to msdyn_kbattachment table
     
    So if you have knowledgearticleid for knowledgearticle table, you can retrieve related attachments as follows.
     
    Fetch Query:-
     
    <fetch>
      <entity name="knowledgearticle">
        <attribute name="knowledgearticleid" />
        <filter>
          <condition attribute="knowledgearticleid" operator="eq" value="32b90f18-abf7-ea11-a815-000d3a1b14a2" />
        </filter>
        <link-entity name="msdyn_msdyn_kbattachment_knowledgearticle" from="knowledgearticleid" to="knowledgearticleid" intersect="true">
          <link-entity name="msdyn_kbattachment" from="msdyn_kbattachmentid" to="msdyn_kbattachmentid" alias="ka">
            <attribute name="msdyn_filename" />
            <attribute name="msdyn_filetype" />
            <attribute name="msdyn_filesize" />
            <link-entity name="fileattachment" from="fileattachmentid" to="msdyn_fileattachment" link-type="outer" alias="fa">
              <attribute name="body" />
            </link-entity>
          </link-entity>
        </link-entity>
      </entity>
    </fetch>
     
    ODATA 4.0 (WebAPI equivalent query):-
     
    https://<orgid>.crm8.dynamics.com/api/data/v9.2/knowledgearticles?$select=knowledgearticleid&$expand=msdyn_msdyn_kbattachment_knowledgearticle($select=msdyn_filename,msdyn_filetype,msdyn_filesize;$expand=msdyn_fileattachment($select=body))&$filter=(knowledgearticleid eq 32b90f18-abf7-ea11-a815-000d3a1b14a2) and (msdyn_msdyn_kbattachment_knowledgearticle/any(o1:(o1/msdyn_kbattachmentid ne null)))
     
     
    If this answers your question, please accept the same

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Hamza H Profile Picture

Hamza H 140 Super User 2026 Season 1

#2
Nagaraju_Matta Profile Picture

Nagaraju_Matta 128

#3
Abhilash Warrier Profile Picture

Abhilash Warrier 70 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans