首页
\
问答
\
服务器未识别json,使用restSharp发送请求(Server is not Recognizing the json, sending request using restSharp)
服务器未识别json,使用restSharp发送请求(Server is not Recognizing the json, sending request using restSharp)
我试图将一些json发布到jboss服务。 使用restSharp ..我的代码如下。
RestClient client = new RestClient(baseURL); RestRequest authenticationrequest = new RestRequest(); authenticationrequest.RequestFormat = DataFormat.Json; authenticationrequest.Method = Method.POST; authenticationrequest.AddParameter("text/json", authenticationrequest.JsonSerializer.Serialize(prequestObj), ParameterType.RequestBody);
并试过这一个
RestClient client = new RestClient(baseURL); RestRequest authenticationrequest = new RestRequest(); authenticationrequest.RequestFormat = DataFormat.Json; authenticationrequest.Method = Method.POST; authenticationrequest.AddBody(authenticationrequest.JsonSerializer.Serialize(prequestObj));
但在这两种情况下我的服务器都给我一个json格式不正确的错误
i am trying to post some json to jboss services. using restSharp.. my code is as follows.
RestClient client = new RestClient(baseURL); RestRequest authenticationrequest = new RestRequest(); authenticationrequest.RequestFormat = DataFormat.Json; authenticationrequest.Method = Method.POST; authenticationrequest.AddParameter("text/json", authenticationrequest.JsonSerializer.Serialize(prequestObj), ParameterType.RequestBody);
and also tried this one
RestClient client = new RestClient(baseURL); RestRequest authenticationrequest = new RestRequest(); authenticationrequest.RequestFormat = DataFormat.Json; authenticationrequest.Method = Method.POST; authenticationrequest.AddBody(authenticationrequest.JsonSerializer.Serialize(prequestObj));
but in both cases my server is giving me error that json is not in correct format
原文:https://stackoverflow.com/questions/16167533
更新时间:2022-10-21 06:10
最满意答案
一种选择是:
注意:我将
div.btn-group
外部的hidden
输入移动到按钮组上有一个很好的边框半径。$('button').click(function() { //Remove class selected on all buttons $(this).parents('fieldset').find('button').removeClass('selected'); //Add class the clicked button $(this).addClass('selected'); //Update the hidden field of the value $(this).parents('fieldset').find('input[type="hidden"]').val( $(this).text() ); })
.selected { background-color: red!IMPORTANT; }
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script> <fieldset id="card_type_fieldset"> <legend>Card Type</legend> <div class="btn-group btn-group-justified" role="group"> <div class="btn-group" role="group"> <button type="button" class="btn btn-default">Visa</button> </div> <div class="btn-group" role="group"> <button type="button" class="btn btn-default">Master</button> </div> <div class="btn-group" role="group"> <button type="button" class="btn btn-default">Amex</button> </div> <div class="btn-group" role="group"> <button type="button" class="btn btn-default">Discover</button> </div> </div> <input type="hidden" name="card_type" value="" /> </fieldset> <fieldset id="ticket_type_fieldset"> <legend>Ticket Type</legend> <div class="btn-group btn-group-justified" role="group"> <div class="btn-group" role="group"> <button type="button" class="btn btn-default">Regular</button> </div> <div class="btn-group" role="group"> <button type="button" class="btn btn-default">VIP</button> </div> </div> <input type="hidden" name="ticket_type" value="" /> </fieldset>
使用Bootstrap 4
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous"> <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script> <div class="btn-group btn-group-toggle" data-toggle="buttons"> <label class="btn btn-secondary active"> <input type="radio" name="options" id="option1" autocomplete="off" checked> Active </label> <label class="btn btn-secondary"> <input type="radio" name="options" id="option2" autocomplete="off"> Radio </label> <label class="btn btn-secondary"> <input type="radio" name="options" id="option3" autocomplete="off"> Radio </label> </div>
Doc: Radio Buttons
One option is:
Note: I moved the
hidden
input outside thediv.btn-group
to have a nice border radius on the button group.$('button').click(function() { //Remove class selected on all buttons $(this).parents('fieldset').find('button').removeClass('selected'); //Add class the clicked button $(this).addClass('selected'); //Update the hidden field of the value $(this).parents('fieldset').find('input[type="hidden"]').val( $(this).text() ); })
.selected { background-color: red!IMPORTANT; }
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script> <fieldset id="card_type_fieldset"> <legend>Card Type</legend> <div class="btn-group btn-group-justified" role="group"> <div class="btn-group" role="group"> <button type="button" class="btn btn-default">Visa</button> </div> <div class="btn-group" role="group"> <button type="button" class="btn btn-default">Master</button> </div> <div class="btn-group" role="group"> <button type="button" class="btn btn-default">Amex</button> </div> <div class="btn-group" role="group"> <button type="button" class="btn btn-default">Discover</button> </div> </div> <input type="hidden" name="card_type" value="" /> </fieldset> <fieldset id="ticket_type_fieldset"> <legend>Ticket Type</legend> <div class="btn-group btn-group-justified" role="group"> <div class="btn-group" role="group"> <button type="button" class="btn btn-default">Regular</button> </div> <div class="btn-group" role="group"> <button type="button" class="btn btn-default">VIP</button> </div> </div> <input type="hidden" name="ticket_type" value="" /> </fieldset>
Using Bootstrap 4
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous"> <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script> <div class="btn-group btn-group-toggle" data-toggle="buttons"> <label class="btn btn-secondary active"> <input type="radio" name="options" id="option1" autocomplete="off" checked> Active </label> <label class="btn btn-secondary"> <input type="radio" name="options" id="option2" autocomplete="off"> Radio </label> <label class="btn btn-secondary"> <input type="radio" name="options" id="option3" autocomplete="off"> Radio </label> </div>
Doc: Radio Buttons
相关问答
更多-
当窗口宽度不够时,列彼此重叠。 所以,如果你编写col-lg-6并且窗口宽度小于lg断点的宽度,那么这些列将会相互重叠。 Bootsrap 3和4有不同的断点,这就是为什么你看到它们之间的差异。 ( Bootstrap 3断点和Bootstrap 4断点 ) 尝试使用col-md-6编写col-lg-6 。 Columns get on top of each other when the window width is not enough for them. So if you write col-lg ...
-
.nav-logo, .caption.text-left { color: #eee; } .logocaption { display: inline-block; vertical-align: middle; }