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 Pages / Issue with setting fil...
Power Pages
Answered

Issue with setting file name during upload using Dataverse Web API

(0) ShareShare
ReportReport
Posted on by 187

Hello,

I'm having a major problem with a Power Pages site in production and I'm looking for advice on how to solve the problem. As of today (no changes made lately), the method I was using to specify file names during uploads has stopped working, causing the file upload to crash. Previously, I used the x-ms-file-name request parameter to set file names when downloading via an API call, as follows:

webapi.safeAjax({
 type: "PUT",
 url: "/_api/cg_commandes([commande_id])/cg_fichierstl?x-ms-file-name=FileName.stl",
 ...
});


However, this approach now results in a 404 (Not Found) error, specifically stating that the x-ms-file-name query parameter is not supported. Removing this parameter allows the request to go through, but then I lose the ability to set the file name, which is crucial for my application's functionality.


In this situation, I'm looking for advice (urgent if possible) on how to specify file names in this situation. Is there a new recommended method for doing this, or a workaround that you are aware of? Any ideas or suggestions would be greatly appreciated!

 

Thank you in advance for your help,

Charles

Categories:
I have the same question (0)
  • OOlashyn Profile Picture
    3,496 Most Valuable Professional on at

    Hi @CharlesPP,

    As a workaround you can try to use Cloud flow and upload your file through it - there you can specify the file name as just an additional variable. You can refer to my article (see discussion for errors and possible workarounds) https://www.dancingwithcrm.com/calling-cloud-flows-in-power-pages/ and official MS docs - https://learn.microsoft.com/en-us/power-pages/configure/cloud-flow-integration. I would also recommend you open a support ticket with MS regarding this issue. 

  • Verified answer
    CharlesPP Profile Picture
    187 on at

    Thank you @OOlashyn for this suggestion, it would have been a functional solution, although it would have required some time to be adapted to my context.

    I found a solution that required very little development for the bug encountered, here it is (use beforeSend) : 

    webapi.safeAjax({
     type: "PUT",
     url: "/_api/cg_commandes(" + newRecordId + ")/cg_fichierstl",
     contentType: "application/octet-stream",
     processData: false,
     data: buffer,
     beforeSend: function(xhr) {
     xhr.setRequestHeader("x-ms-file-name", "FileName.stl");
     },
     success: function (res, status, xhr) {
     console.log("File attached successfully", "Response:", res);
     },
     error: function (xhr, status, error) {
     console.error("File Attachment Error:", error, "Status:", status, "Response:", xhr.responseText);
     }
    });

     

    Best regards,

    Charles

  • Sahil Profile Picture
    132 on at

    Thank you for sharing this! It really saved my day.

    I've been encountering this issue across all our environments (DEV, UAT, and PROD, etc.) all of a sudden. I'm curious, how did you discover this parameter - beforehand? I couldn't locate it on the MSDN blogs I was browsing.

  • CharlesPP Profile Picture
    187 on at

    I'm glad to know I helped someone! I also lost a day with this problem.

     

    I looked for other ways to send the parameter in a JavaScript HTTP request (since that's what was in error) and found this. You should also be able to use "headers" instead of "beforeSend".

     

    Best regards,

    Charles

  • Sahil Profile Picture
    132 on at

    Great! Thanks a lot for sharing.

     

    I think you can mark your answer above as an accepted solution, it may help others.

     

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 Pages

#1
Fubar Profile Picture

Fubar 74 Super User 2025 Season 2

#2
Jerry-IN Profile Picture

Jerry-IN 55

#3
sannavajjala87 Profile Picture

sannavajjala87 31

Last 30 days Overall leaderboard