ios - 如何在参数下发送发布请求?
<p><p>我有一些参数可以向服务器发送 post 请求:</p>
<pre><code>`[{"LoginID":151,"UserID":0,"SubUserID":0,"WorkGroupID":92,"WorksFor":"Doctor","UserWorkGroup":0},{"SearchingFilters":{"GroupingOperator":"And","Filters":[{"SearchingValue":"04-13-2016","SearchingName":"AppointmentDate","SearchingOperator":"Ge"},{"SearchingValue":"04-27-2016","SearchingName":"AppointmentDate","SearchingOperator":"Le"}],"Groups":[{"Groups":[],"GroupingOperator":"And","Filters":[]}]},"Searching":true,"SortingOrder":"Desc","RecordsCount":10,"PageIndex":0}]`
</code></pre>
<p>如何以这种格式发送?</p>
<pre><code> initWithObjectsAndKeys:[ objectForKey:@"USER_ID"],@"LoginID",@"0",@"UserID",@"0",@"SubUserID",[ objectForKey:@"WORK_ID"],@"WorkGroupID",@"Doctor",@"WorksFor",@"0",@"UserWorkGroup",nil] andRequestType:@"POST"];
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>首先你需要使用json格式发送请求,而不是直接作为对象</p>
<p>第二个</p>
<p>我认为服务需要改变</p>
<p>服务应该以这种格式接受您的请求。</p>
<pre><code>{
"LoginID": 151,
"UserID": 0,
"SubUserID": 0,
"WorkGroupID": 92,
"WorksFor": "Doctor",
"UserWorkGroup": 0,
"SearchingFilters": {
"GroupingOperator": "And",
"Filters": [
{
"SearchingValue": "04-13-2016",
"SearchingName": "AppointmentDate",
"SearchingOperator": "Ge"
},
{
"SearchingValue": "04-27-2016",
"SearchingName": "AppointmentDate",
"SearchingOperator": "Le"
}
],
"Groups": [
{
"Groups": [
],
"GroupingOperator": "And",
"Filters": [
]
}
]
},
"Searching": true,
"SortingOrder": "Desc",
"RecordsCount": 10,
"PageIndex": 0
}
</code></pre>
<p>如果您需要将其作为单个对象传递,否则如果在请求中发送多个对象,则将其添加到数组中</p></p>
<p style="font-size: 20px;">关于ios - 如何在参数下发送发布请求?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/37043084/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/37043084/
</a>
</p>
页:
[1]