Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Inbound JSON Serialization Error

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I'm trying to consume an inbound JSON file I've also tried with code that duplicates it here.  The client crashes at the JsonTextReader statement and throws the following error:   

Type: System.Runtime.Serialization.SerializationException
Message: <ii>Type 'System.IO.StringReader' with data contract name 'StringReader: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>

ReadString := '{';
ReadString :=  ReadString.ToString + '"odata.metadata": "nav2018/.../OData$metadata#ScionCostComponents",';
ReadString :=  ReadString.ToString + '"value": [';
ReadString :=  ReadString.ToString + '{';
ReadString :=  ReadString.ToString + '"Code": "TEST",';
ReadString :=  ReadString.ToString + '"Descripiton": "Test1",';
ReadString :=  ReadString.ToString + '"Cost_Account_No": "",';
ReadString :=  ReadString.ToString + '"Cost_Account_Balance": "0",';
ReadString :=  ReadString.ToString + '"Applied_Account_No": "14200",';
ReadString :=  ReadString.ToString + '"Applied_Account_Balance": "0",';
ReadString :=  ReadString.ToString + '"Date_Filter": "0001-01-01T00:00:00"';
ReadString :=  ReadString.ToString + '}';
ReadString :=  ReadString.ToString + ']';
ReadString :=  ReadString.ToString + '}';

String := JsonConvert.SerializeObject(ReadString);
StringReader := StringReader.StringReader(String);
JsonTextReader := JsonTextReader.JsonTextReader(StringReader);

*This post is locked for comments

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 Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,492 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans