OStack程序员社区-中国程序员成长平台

标题: ios - 如何在参数下发送发布请求? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 19:44
标题: ios - 如何在参数下发送发布请求?

我有一些参数可以向服务器发送 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,"ageIndex":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"OST"];



Best Answer-推荐答案


首先你需要使用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,
  "ageIndex": 0
}

如果您需要将其作为单个对象传递,否则如果在请求中发送多个对象,则将其添加到数组中

关于ios - 如何在参数下发送发布请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37043084/






欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) Powered by Discuz! X3.4