Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

Can't update attachment with API v2

Posted on by
Using API v2 and `PATCH` to update attachments, keep getting corrupted files. 
I'm using javascript with this logic to create the stream: 
    const readableStream = new Readable();
    // eslint-disable-next-line @typescript-eslint/no-empty-function
    readableStream._read = () => {};
    readableStream.push(fileContent);
    readableStream.push(null);
 
This is the headers: 
Accept: 'application/json',
      'Content-Type': 'application/json; odata.metadata=minimal; odata.streaming=true',
      'IF-MATCH': '*',
      'User-Agent': 'axios/0.26.0',
      'Content-Length': 413658

 
 
What am I doing wrong?
Categories:
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,647 Super User 2024 Season 2 on at
    Can't update attachment with API v2
    Hi, I suspect it's an Endpoint problem.
    The first thing to note is that this standard Attachment API is not Document Attachment (table 1173), but Incoming Document (table 130). Second, this requires specifying the parent ID.
     
    Although not exactly the same, I mention this in the post below in hopes of giving you some tips.
    How to automatically upload files from OneDrive to Business Central with Power Automate (No customization)
    https://yzhums.com/39365/
     
    Thanks.
    ZHU

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans