Grizabela
Grizabela

Reputation: 165

Postman fails to return json from asmx service

I have WebService and I'm using Postman to test it. But it keeps returning xml. I tried using [ScriptMethod(ResponseFormat = ResponseFormat.Json,UseHttpGet =false)] in my WebMethod, also in postman the request is http://localhost:port/folder/service.asmx/HelloWorld. In the config File I Have

  <handlers>
  <add name="ScriptHandlerFactory" verb="*" path="*.asmx" type="System.Web.Script.Services.ScriptHandlerFactory,  System.Web.Extensions,  Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" resourceType="Unspecified" />
  </handlers>

It still doesn't work and Postman returns xml

Upvotes: 0

Views: 1080

Answers (2)

Grizabela
Grizabela

Reputation: 165

i'm posting the answer: I just uncommented:

[System.Web.Script.Services.ScriptService]

Upvotes: 1

user2922221
user2922221

Reputation:

You need to add reference from nuget packager for "Newtonsoft.Json" so you will be able to return data in JSON format.

return JsonConvert.SerializeObject(DataSet, Newtonsoft.Json.Formatting.Indented);

Upvotes: 0

Related Questions