Question JSON processing in Visual Studio 2013 with IIS8 "=" have to be first

JirkaH77

New member
Joined
Nov 21, 2019
Messages
4
Programming Experience
10+
I would like to process JSON in WepAPI 2.0 and in the JSON file must be = as a first char.
If I post normal JSON [{ ... }] visual studio return NULL exception and variable "value" is NULL

namespace MyProgram.Controllers
{
public class TestController : ApiController
{
// POST: api/test
public string Post([FromBody]string value)
{
value = value.Replace("\t", "");
List<Test> r;

r = JsonConvert.DeserializeObject<List<Test>>(value);

.....
}
}
}
 
If the JSON file has '=' as the first character, then it is not legal JSON. See the railroad tracks on json.org. There is no path the begins with a '='.
 
Also, when you are POSTing, to your API, is the content type set to application/json?

From my reading on StackOverflow, if you use application/x-www-form-urlencoded, then the '=' needs to be there for the sake of the body parser/binder, not for the sake of the JSON data itself.
 
Also, when you are POSTing, to your API, is the content type set to application/json?

From my reading on StackOverflow, if you use application/x-www-form-urlencoded, then the '=' needs to be there for the sake of the body parser/binder, not for the sake of the JSON data itself.

I tryied Postman and in cmd I am trying this
1574411413740.png
 

Attachments

  • 1574411316412.png
    1574411316412.png
    115.1 KB · Views: 25
You was right ... before this try I was really using curl without -H "Content-Type: appplication/json" and verbose mode wrote me then I am using "application/x-www-form-urlencoded", but with -H "Content-Type: appplication/json" does not work JSON with = and regular JSON too

still return Null.Exception
 
Last edited:
Back
Top Bottom