0

I want to send this parameter

   {Id:1,
    Comment:{Content:'comment 1'}
   }

I wrote this

   var content = "comment 1"
   let content: [String : String] = ["Content":"\(content)"] 
   let params: [String : AnyObject]=["Comment":"\(content)", "Id":"123"]

but not work

Cœur
  • 34,719
  • 24
  • 185
  • 251
idris yıldız
  • 2,077
  • 19
  • 21

2 Answers2

1

ok My question is true but when my content is numbers

my parameter has a "Optional()" because of that ı get error now ı fixed it like that

var content = "comment 1"
let content: [String : String] = ["Content": content] 
let params: [String : AnyObject]=["Comment": content, "Id":"123"]

it is work very well

idris yıldız
  • 2,077
  • 19
  • 21
0

You have var content and let content. You can't do this. Maybe its the problem. Try it:

let contents = ["Content":"comment 1"] 
let params = ["Comment":"\(contents)", "Id":"123"]
println(params) //prints: [Comment: [Content: comment 1], Id: 123]
Alamofire.request(.POST, "http://example.com/post", parameters: params)
Klevison
  • 3,252
  • 1
  • 17
  • 28