E
E
Evgeny Zapunny2022-03-28 18:00:40
API
Evgeny Zapunny, 2022-03-28 18:00:40

Why is swift not sending requests?

There is a server that responds remarkably to requests through the client side or through postman, in the application I use this code

guard let url = URL(string: "https://***.***.***.***/auth/login") else {
     completion(.failure(.custom(errorMessage: "URL is not correct")))
     return
}
var request = URLRequest(url: url)

request.httpMethod = "POST"
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try? JSONEncoder().encode(body)

to which I get this answer
The operation couldn’t be completed. (test.AuthenticationError error 1.)

requests to the server never arrive
ps
https uses a normal ssl certificate

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Araya, 2022-03-28
@Araya

So you don’t have a method for executing the request, you just prepared it. Alya:
URLSession.shared.dataTask(with: request)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question