fetch customerId for myApiClient

You should first check that let customerId = defaults.string(forKey: "customerId") provides a valid customerId. You can do so by debugging your app and inspecting the value of customerId. Assuming that it is valid, I see a couple of things that may be causing issues for you:

The Alamofire library that you are using has 2 Parameter Encoders with different properties and options. You can see them here. My hypothesis is that you are nor passing the customerId correclty to the body of the request. I suggest you start by trying the JSONParameterEncoder. Your request would be somehting like this:

AF.request(url, method: .post, parameters: [
  "api_version": apiVersion, "customer_id": customerId!
  encoder: JSONParameterEncoder.default)

It is possible that you also have to tweak the way your retrieve the customerID from the Cloud Function according to how you pass the info from the swift app. This docs may provide some insights on how to parse HTTP request info

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top