Note that there are some explanatory texts on larger screens.

plurals
  1. POError 400 bad request JqGrid
    primarykey
    data
    text
    <p>I try to "POST" data, but when i'm doing it, i'm getting ERROR 400. I have the same issue with "UPDATE" data. I have no idea how to solve this problem. </p> <p>This is my jqgrid code: $(function() {</p> <pre><code> $.extend($.jgrid.defaults, { datatype: 'json', jsonReader : { repeatitems:false, total: function(result) { //Total number of pages return Math.ceil(result.total / result.max); }, records: function(result) { //Total number of records return result.total; } }, prmNames: { rows: 'max', search: null }, height: 'auto', viewrecords: true, rowList: [10, 20, 50, 100], altRows: true, loadError: function(xhr, status, error) { alert(error); } }); $.extend($.jgrid.edit, { closeAfterEdit: true, closeAfterAdd: true, ajaxEditOptions: { contentType: "application/json" }, mtype: 'PUT', serializeEditData: function(data) { delete data.oper; return JSON.stringify(data); } }); $.extend($.jgrid.del, { mtype: 'DELETE', serializeDelData: function() { return ""; } }); var editOptions = { onclickSubmit: function(params, postdata) { params.url = URL + '/' + postdata.id; } }; var addOptions = { mtype: "POST" }; var delOptions = { onclickSubmit: function(params, postdata) { params.url = URL + '/' + postdata; } }; var URL = 'rest/poll'; var options = { url: URL, editurl: URL, colModel:[ { name:'id', label: 'ID', formatter:'integer', width: 40, editable: true, editoptions: { disabled: true, size:5 } }, { name: 'categories.name', index: 'categories', label: 'Category', editable: true, edittype: "select", viewrecords:true, editoptions: { dataUrl:"rest/category/list.do", buildSelect: function (list) { var data = jQuery.parseJSON(list); var s = '&lt;select&gt;'; for (var i = 0; i &lt; data.locationList.length; i++) { s += '&lt;option value="' + data.locationList[i] + '"&gt;' + data.locationList[i].name + '&lt;/option&gt;'; } return s + "&lt;/select&gt;"; } } }, { name:'name', label: 'Name', width: 300, editable: true, editrules: { required: true } }, { name: 'MyLink', formatter: myLinkFormatter } ], caption: "Polls", pager : '#pager', height: 'auto', ondblClickRow: function(id) { jQuery(this).jqGrid('editGridRow', id, editOptions); } }; $("#grid") .jqGrid(options) .navGrid('#pager', {}, //options editOptions, addOptions, delOptions, {} // search options ); }); function myLinkFormatter (cellvalue, options, rowObjcet) { return '&lt;a href = "/Polls_V2/options?categoryId=' + options.rowId + '"&gt;Answers&lt;/a&gt;'; } </code></pre> <p>And this my controller code : </p> <pre><code> @RequestMapping(method = RequestMethod.POST) public ResponseEntity&lt;String&gt; createCategory(HttpServletRequest request, @RequestBody Polls polls) { pollsService.add(polls); URI uri = new UriTemplate("{requestUrl}/{username}").expand(request.getRequestURL().toString(), polls.getId()); final HttpHeaders headers = new HttpHeaders(); headers.put("Location", Collections.singletonList(uri.toASCIIString())); return new ResponseEntity&lt;String&gt;(headers, HttpStatus.CREATED); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload