Forum Discussion

Ravi_K's avatar
Ravi_K
Occasional Visitor
6 years ago
Solved

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. 

  • 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

  • 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.