1

Error:

ERROR HERE: Optional(Error Domain=com.amazonaws.AWSJSONBuilderErrorDomain Code=4 "serialized object is neither a valid json Object nor NSData object: " UserInfo={NSLocalizedDescription=serialized object is neither a valid json Object nor NSData object: })

Code:

import AWSLambda
import Foundation
struct AWSHelper{
let lambda = AWSLambda.default()
let APPLICATION_NAME = "MYAPPNAME"
init(){

}

func getFunctionName(funcName: String) -> String{
    return "\(funcName)_\(APPLICATION_NAME)"
}

func login(facebookID: String,cognitoID:String, callback:@escaping (Bool) -> Void){
    let req: AWSLambdaInvocationRequest = AWSLambdaInvocationRequest();
    req.invocationType = AWSLambdaInvocationType.requestResponse
    req.payload = ["cognitoID" : cognitoID, "facebookID" : facebookID]
    req.functionName = getFunctionName(funcName: "Login")

    lambda.invoke(req) { (response: AWSLambdaInvocationResponse?,error: Error?) in
        print("ERROR HERE: \(error)")
        let payload = response?.payload
        print("PAYLOAD HERE: \(payload)")
        callback(true)
    }

}
}

I have looked at my lambda logs and I can see that I am not even invoking the method. What is the issue I am facing? I have another suspicion that it might be cognito here: AWS Cognito integration swift3 Refresh provides ResourceNotFoundException
But I'm confused if I am able to get an identityID, what is going wrong? Now I am thinking it might be my lambda invocation.

Community
  • 1
  • 1
user2977578
  • 413
  • 5
  • 19

1 Answers1

1

I don't know if this would help you. Looking at your invoke request it is missing two items. ClientContext and Qualifier. Those would be empty.

At 1292 in AWSSerialization it has:

            [self failWithCode:AWSJSONBuilderInvalidParameter description:[NSString stringWithFormat:@"serialized object is neither a valid json Object nor NSData object: %@",serializedJsonObject] error:error];

note that after the : you should see the object you are serializing. In your error it is empty.

Maybe use a breakpoint and backtrace to see what it is working on.

Bruce0
  • 2,718
  • 1
  • 17
  • 21
  • I actually don't think this is Lambda anymore. If I take out my facebook token then it complains that my unauth role isn't authorized which also means that it is executing the command properly. However when I add facebook I get the error so I think it has to do with my credentials instead. – user2977578 Nov 07 '16 at 18:17
  • I don't know what changed but I stopped working on it for a week and it started working... I'll look at my diffs and post my thoughts in the other question – user2977578 Nov 07 '16 at 18:22