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
  • 37,241
  • 25
  • 195
  • 267
idris yıldız
  • 2,097
  • 20
  • 22

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,097
  • 20
  • 22
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,342
  • 2
  • 19
  • 32