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

Announcements

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

REST API POST request to upload a file

(0) ShareShare
ReportReport
Posted on by 256
Hello,
 
I'm struggeling implementing a HTTP Post Request to upload a file to a 3rd party application. I found a nice how-to which covers my requirenment almost exactly:
 
 
The only problem I have is the "authentification". My 3rd party application handles the authentification via "cookies" not with request header (ClientID / ClientSECRECT) like in the example.
 
I already have a working http get request to download a file using the "cookie authentification":
 
 
The example is using the "System.Net.Http.HttpRequestMessage" instead of "System.Net.HttpWebRequest":
 
 
I see two possible ways to close the gap on both sides:
 
1. Implement the "cookie authentification" with "System.Net.Http.HttpRequestMessage"
2. Implement the "file content transfer" (Multipart/Form-data) with "System.Net.HttpWebRequest"
 
I would be very grateful for any information about the two solutions.
 
Sebastian
Categories:
I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    238,653 Most Valuable Professional on at
    The example seems to be using HttpClient, which is the recommended replacement of the obsolete HttpWebRequest that you're using in your code. So, the recommendation from Microsoft is switching to HttpClient/HttpRequestMessage.
  • Diego Mancassola Profile Picture
    539 on at
    Hi Sebastian,
     
    I think there is a bit of confusion in your approach 🙂
     
    You don’t need to mix HttpWebRequest and HttpRequestMessage. You can do everything — cookie authentication and multipart file upload — using HttpRequestMessage together with HttpClient. The HttpWebRequest is obsolete.

    There is no technical gap between the two APIs in your scenario.
     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 721 Super User 2026 Season 1

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 280 Super User 2026 Season 1

#3
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 255

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans