0

My backend expects the following json for login.

{
"userName": "username",
"password" : "password",
"deviceInfoObj": {
"uniqueId":"q33qq3wr3wrw",
"model" : "6S"
}
}

Here is what I have

let deviceInfoObj: [String : String] = [
                    "uniqueId": "4d600df2c7e7c55",
                    "model": "6S"
            ]

let loginParams: [String:String] = [
                "userName": String(uname) ,
                "password" : String(pwd),
                "deviceInfo": deviceInfoObj

Here is how I make the request.

engine.sendRequestWithParms(loginParams, serviceUrl: NSURL(string: urlString)).

I get build error:

cannot-convert-value-of-type-string-string-to-expected-argument-type-string

1 Answer 1

1

try this:

let loginParams: [String: AnyObject] = [
  "userName": String(uname) ,
  "password" : String(pwd),
  "deviceInfo": deviceInfoObj
]
Sign up to request clarification or add additional context in comments.

3 Comments

should that be "let deviceInfoObj" or "let loginParams"?
Edited, sorry for typo
Thread 42: "Invalid type in JSON write (__SwiftValue)"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.