I'm trying to hit an API URL, however I am getting this error
(501) Invalidation handler invoked, clearing connection
(501) personaAttributesForPersonaType for type:0 failed with error Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.mobile.usermanagerd.xpc was invalidated: failed at lookup with error 159 - Sandbox restriction."
UserInfo={NSDebugDescription=The connection to service named com.apple.mobile.usermanagerd.xpc was invalidated: failed at lookup with error 159 - Sandbox restriction.}
Received port for identifier response: <(null)> with error:Error Domain=RBSServiceErrorDomain Code=1 "Client not entitled" UserInfo={RBSEntitlement=com.apple.runningboard.process-state, NSLocalizedFailureReason=Client not entitled, RBSPermanent=false}
elapsedCPUTimeForFrontBoard couldn't generate a task port
This is what my info.plist looks like -
This is the code I'm using to hit the URL and get a response
func sendMessage() {
guard let url = URL(string: "https://API_URL") else { return }
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let body = ["query": message] //creates a dictionary with key:value pair
request.httpBody = try? JSONSerialization.data(withJSONObject: body) //converts the dictionary to json data and sets as body of request
isLoading = true
response = ""
URLSession.shared.dataTask(with: request) { data, _, error in //initiates async task for sending request
DispatchQueue.main.async { //async update of UI on main thread
isLoading = false
}
if let data = data, error == nil, //checks that data was received and that there is no error
let json = try? JSONSerialization.jsonObject(with: data) as? [String: String] { //parsing json response
DispatchQueue.main.async {
response = json["response"] ?? "No response"
}
}
}.resume() // starts the network request
}
Can anyone help me understand what the errors are and why I'm not able to get the response back?
1
0
494