我有一些参数可以将post请求发送到服务器:
`[{"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}]`
如何以这种格式发送?
[getProfileServices sendSynchronousPostRequestWithStringForAction:getProfileURL andParameters:[[NSDictionary alloc] initWithObjectsAndKeys:[[NSUserDefaults standardUserDefaults] objectForKey:@"USER_ID"],@"LoginID",@"0",@"UserID",@"0",@"SubUserID",[[NSUserDefaults standardUserDefaults] objectForKey:@"WORK_ID"],@"WorkGroupID",@"Doctor",@"WorksFor",@"0",@"UserWorkGroup",nil] andRequestType:@"POST"];
答案 0 :(得分:1)
首先,您需要使用json格式发送请求而不是直接作为对象
第二次
我认为需要改变服务
服务应以此格式接受您的请求。
{
"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
}
如果您需要将其作为单个对象传递,则在请求中发送多个对象时将其添加到数组中
答案 1 :(得分:1)
@Raghvendra首先在字典中设置参数以传递参数然后设置你的网址 在这里输入代码
var str = "dabcehklopqrsafxwvu012345678910210";
var res = Array.prototype.reduce.call(str, function(acc, item, index, strAr) {
var pushItem =
//first item always included
index === 0 ||
// last item always included
index === strAr.length - 1 ||
// include the first item in sequence
strAr[index - 1].charCodeAt(0) + 1 !== item.charCodeAt(0) ||
// include the last item in sequence
strAr[index + 1].charCodeAt(0) - 1 !== item.charCodeAt(0)
if (pushItem) {
acc += item;
}
return acc;
}, '');
console.log(res); // prints "dacehklosafxwvu0910210"