1

dashBoardApplyListCriteria
Here dashBoardApplyListCriteria parameter is a dictionary. How can pass dictionary as a parameter in swift ios.

Here is my code

let parameters: NSDictionary = [ "sessionId":sessionId, "jobId":jobId, "dashBoardApplyListCriteria":["1":["Recruiter"], "selectedBucketStatus":"Applies", "allJobsOrMyJobs":"AllJobs", "jobStatus":[0,1,2], "paginationStartNo":0, "paginationHowMuch":5], ] ]

    let parameters: [String: Any] =
        [
        "sessionId":sessionId,
        "jobId":jobId,
        "dashBoardApplyListCriteria":["actorList":["Recruiter"],
                                      "selectedBucketStatus":"Applies",
                                      "allJobsOrMyJobs":"AllJobs",
                                      "jobStatus":[0,1,2],
                                      "paginationStartNo":0,
                                      "paginationHowMuch":5],
        "applyListFilterCriteria":["appliesToBeSorted":["name":"dateApply","isAscending":true]]
    ]

let jsonData = try? JSONSerialization.data(withJSONObject: parameters)

Prasad A
  • 77
  • 7
  • 1
    What did you try so far and what went wrong? – Nikolai Shevchenko Mar 23 '18 at 09:48
  • let parameters: NSDictionary = [ "sessionId":sessionId, "jobId":jobId, "dashBoardApplyListCriteria":["1":["Recruiter"], "selectedBucketStatus":"Applies", "allJobsOrMyJobs":"AllJobs", "jobStatus":[0,1,2], "paginationStartNo":0, "paginationHowMuch":5], ] ] – Prasad A Mar 23 '18 at 10:07
  • Any solutions. Thanks in advance. – Prasad A Mar 23 '18 at 10:28
  • Possible duplicate of [How to make HTTP Post request with JSON body in Swift](https://stackoverflow.com/questions/31937686/how-to-make-http-post-request-with-json-body-in-swift) – Larme Mar 23 '18 at 10:53
  • You seem to be using postman. Click on `Code` in top right next to cookies and select `Swift` in top left of pop-up. It will give you the code. – dispatchMain Mar 23 '18 at 11:27
  • I tried the swift code of postman but it did not work for me. – Prasad A Mar 23 '18 at 11:49
  • Any Solutions!! – Prasad A Mar 23 '18 at 13:25
  • How do you know it's not working? Could be because of App Transport Security? Because your code using URLSession is wrong? Because you don't know that the URLSession code is async and don't know how to manage it? Where did you put `jsonData` to `yourURLRequest.HTTPBody`? Is `jsonData` nil? You did a try?, no `catch`? – Larme Mar 24 '18 at 09:28
  • Thanks Larme. But the problem was with parameter, the dashboard ApplyList criteria was in string. I got the solutions after converting dashboard ApplyList criteria from dictionary to string. And converting whole parameter from "form data" format to "raw data" by appending "&". – Prasad A Mar 26 '18 at 06:38

0 Answers0