API Call from inside Vision Pro

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 -

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>CFBundleIcons.CFBundlePrimaryIcon</key> <string>AppIcon</string> <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict> <key>NSHandsTrackingUsageDescription</key> <string>Enable Hand Tracking for AR Interactions</string> <key>NSWorldSensingUsageDescription</key> <string>Enable World Sensing for AR interactions</string> <key>UIApplicationSceneManifest</key> <dict> <key>UIApplicationPreferredDefaultSceneSessionRole</key> <string>UIWindowSceneSessionRoleApplication</string> <key>UIApplicationSupportsMultipleScenes</key> <true/> <key>UISceneConfigurations</key> <dict/> </dict> <key>UIBackgroundModes</key> <array> <string>fetch</string> <string>remote-notification</string> <string>processing</string> </array> </dict> </plist>

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?

Hi @adityach

I don't have an immediate answer, but can offer some trouble shooting advice. Try testing against another REST endpoint (ideally one you are familiar with). That will help us determine if the error is specific to the API you are hitting. What sticks out is (501) Invalidation handler invoked, clearing connection (501) personaAttributesForPersonaType, which appears to be a HTTP response code: 501 Not Implemented. It may be that personaAttributesForPersonaType does not exist or you are sending an invalid request. Are you able to hit the API via other means? Is so double check the request parameters, the HTTP method and header. Please let me know how it goes.

API Call from inside Vision Pro
 
 
Q