[Used variables]
StreamContent => System.Net.Http.StreamContent
File = > System.IO.File
FileMode => System.IO.FileMode
Hi,
I'm attempting to post a file on a web API.
I try to send the file into a streamcontent like this:
StreamContent := StreamContent.StreamContent(File.Open('PathToMyFile.tar.gz'), FileMode.Open));
Compilation is ok.
When I run the program, NAV says that the server instance is not available anymore. And the event log says that:
Type: System.Runtime.Serialization.SerializationException Message: <ii>Type 'System.IO.FileStream' with data contract name 'FileStream:schemas.datacontract.org/.../System.IO'
is not expected. Consider using a DataContractResolver if you are using DataContractSerializer or add any types not known
statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list
of known types passed to the serializer.</ii>
To do that I'm working with documentation or questions asked about DotNet classes, which I translate to NAV and I think
I'm missing something in the using of StreamContent Class.
Here is an example given on StackOverflow which puts me in this way.
Thanks for your help !
*This post is locked for comments
Hi, Shouldn't it be like this? StreamContent := StreamContent.StreamContent(File.Open('PathToMyFile.tar.gz', FileMode.Open));
Thanks ! That was it ! :)
Hi,
Shouldn't it be like this?
StreamContent := StreamContent.StreamContent(File.Open('PathToMyFile.tar.gz', FileMode.Open));
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156