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 :
Power Platform Community / Forums / Power Automate / Duplicating SharePoint...
Power Automate
Unanswered

Duplicating SharePoint List Attachments using REST API header issue?

(1) ShareShare
ReportReport
Posted on by

I've got two REST API calls, the first retrieves the base64 data and the second posts it to a different SharePoint List. The action calls are successful and a file gets uploaded to the correct destination, but when opened I get the error message below. Am I missing a header on the REST POST call?

Categories:
I have the same question (0)
  • Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at

    Hi @kk281 

     

    The body parameter which you are getting from first API operation may contains other things as well apart from content of file, so you have to check the body dynamic content by using a compose action and see which property inside represent file content and then use that property's value as input to the second api 

     

    Hope it helps !

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel
    Blog: Nived Nambiar's Blogs

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

     

  • sandeepstw Profile Picture
    312 Moderator on at

    Hi @kk281 ,

     

    It's likely that the issue is related to the format of the base64 data when posting it to the SharePoint List. Ensure that the base64 string is correctly formatted and that the appropriate headers are included in the REST POST call. Specifically, check that the 'Content-Type' header is set to 'application/json;odata=verbose'.

     

    This is sample code which you can use  - 

     

    var url = "www.yourdomainname.com/_api/web/lists/getbytitle('<List Name>')/items";
    var item = {
    "__metadata": { "type": "<ListItemEntityTypeFullName>" },
    "Title": "Test File",
    "File": {
    "__metadata": { "type": "SP.FieldUrlValue" },
    "Description": "Test File",
    "Url": "data&colon;application/octet-stream;base64," + base64Data
    }
    };
    
    $.ajax({
    url: url,
    type: "POST",
    contentType: "application/json;odata=verbose",
    data: JSON.stringify(item),
    headers: {
    "Accept": "application/json;odata=verbose",
    "X-RequestDigest": $("#__REQUESTDIGEST").val()
    },
    success: function (data) {
    console.log("File uploaded successfully");
    },
    error: function (error) {
    console.log(JSON.stringify(error));
    }
    });

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard