0

I Pass the string also one param along with array at API hitting time using Alamofire.

But response time my string read as a nill please anyone suggest to me.

These are my parameters

let apiurl = "https://www.furnitureinfashion.net/FIF-APP/app_array_cart.php?"

let params:[String:Any] = ["customer_id":"152698",
                                   "product_id":["27372","31872"],
                                   "qty":["3","4"],
                                   "option":["1202",""]]

find my API hitting code as following

Alamofire.request(apiurl, method:.get, parameters: params, encoding: JSONEncoding.default).responseJSON { (response) in
   if response.result.value != nil{
     print(response)
   }else{
     print(response.result.error?.localizedDescription ?? "")
   }
}

I get a response like this:

SUCCESS: {
    Message = "Customer id missing";
    cusid = "<null>";
    status = "Not ok";
}
5
  • stackoverflow.com/a/58855389/9136962 Commented Nov 27, 2019 at 9:08
  • Check the server param what actually the customerId param is. Is it cusid or customer_id ? Commented Nov 27, 2019 at 9:09
  • no no correct only Commented Nov 27, 2019 at 9:19
  • What actually the request will be? Is it POST request or GET request? Seems like it will be POST request not GET. Commented Nov 27, 2019 at 9:21
  • it is GET only from Backend. Commented Nov 27, 2019 at 9:28

1 Answer 1

0

This is correct way only based on the backend person required meant we send the format either it is decoded or encode

This is backend issue.

Alamofire.request(apiurl, method:.get, parameters: params, encoding: JSONEncoding.default).responseJSON { (response) in
   if response.result.value != nil{
     print(response)
   }else{
     print(response.result.error?.localizedDescription ?? "")
   }
}
Sign up to request clarification or add additional context in comments.

Comments

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.