Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
GridModel fails to parse Request-Stream when POST-Payload contains an integer array

Hello to all,

I wrote everything in the bottom of this old Thread:

But it is closed now.

So aigain:

I'm using a POST-Payload like this:

{"fromDate":"2020-07-15T14:05:59.420Z","tillDate":"2020-07-15T14:05:59.427Z","mandantIds":[13],"filterDisplayText":"15.07.2020 - 15.07.2020 IMPULS KÜCHEN GMBH - 59916 BRILON","reportId":1}

you get this Exception:

Unexpected character encountered while parsing value: [. Path 'mandantIds', line 1, position 91.

independent how your GridModel looks like:

public static GridModel getGridModel(ControllingReport report, ReportRequestObject request)
            GridModel gridModel = new GridModel();
            gridModel.Height = "100%";
            gridModel.Columns.Add(new GridColumn("Product Name", "Name", "string", "300px"));
            gridModel.DataSource = new  List<string>{"1", "2" };

            return gridModel;

The Reason:

In GridModel.DataBindInternal()

// extracting parameters for POST requests
			if (HttpContext.Current != null && HttpContext.Current.Request.HttpMethod == "POST")
				Stream req = this.HtmlHelper != null ? this.HtmlHelper.ViewContext.HttpContext.Request.InputStream :
				req.Seek(0, SeekOrigin.Begin);
				string json = new StreamReader(req).ReadToEnd();
				if ((json.StartsWith("{") && json.EndsWith("}")) ||
					(json.StartsWith("[") && json.EndsWith("]")))
					var dict = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);
					if (dict != null)
						queryString = dict.Aggregate(new NameValueCollection(queryString),
							(seed, current) => {
								seed.Add(current.Key, current.Value);
								return seed;

This line excpects that the whole payload is only a key/val pair of strings ¯\(°_o)/¯

var dict = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);

But i need to consume complex types in my middleware that I pass with the POST-Payload

Could you investigate to this please? Can help me with a workaround?

Currently I'm testing with setting:

HttpContext.Current = null;

before I return my GridModel that eliminates the Exception.

Kind regards


  • 960
    Verified Answer
    Offline posted

    Hello Karol,

    Thank you for posting in our community.

    I created the following case for you: 'CAS-208357-B7Y3R9' and will update you through it. You could see it in your account in the 'Support Activity' page.