cancel
Showing results for 
Search instead for 
Did you mean: 

Swagger ui throwing an exception for Hashtable when i use Newtonsoft.Json version 12.0.1

SOLVED
Occasional Visitor

Swagger ui throwing an exception for Hashtable when i use Newtonsoft.Json version 12.0.1

When i execute my application it throws an error when i use Newtonsoft.Json 12.0.1 dll :

 

Http Error 500 : { "Message":"An error has occurred.", "ExceptionMessage":"Type System.Collections.Hashtable& is not a dictionary." }

when i use Newtonsoft.Json 11.0.0 dll it works fine

Below is the API method called from the Swagger UI (http://localhost:54738/swagger/ui/index) :

 [HttpGet]
 public SortedList<int, XElement> getVariableStates(string sInstanceID, [FromBody] ref Hashtable oVarsDic)
 {
 }
 

please find the screenshot of exception. 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Moderator

Re: Swagger ui throwing an exception for Hashtable when i use Newtonsoft.Json version 12.0.1

Hi Ravi,

 

Newtonsoft is not one of our projects and we don't know it well enough to provide support for it. The error you're getting is from it and not from Swagger UI. Looking at the stack trace you provided, it looks like it may originate from Swashbuckle, which is again not one of our projects, but it does wrap Swagger UI in it. Your best bet is to file an issue either with Newtonsoft or Swashbuckle and hopefully one of them can help you out.

1 REPLY 1
Highlighted
Moderator

Re: Swagger ui throwing an exception for Hashtable when i use Newtonsoft.Json version 12.0.1

Hi Ravi,

 

Newtonsoft is not one of our projects and we don't know it well enough to provide support for it. The error you're getting is from it and not from Swagger UI. Looking at the stack trace you provided, it looks like it may originate from Swashbuckle, which is again not one of our projects, but it does wrap Swagger UI in it. Your best bet is to file an issue either with Newtonsoft or Swashbuckle and hopefully one of them can help you out.

New Here?
Join us and watch the welcome video:
API Testing Mistake #2
APITestingMistake#2
Top Kudoed Authors