If App Sandbox is enabled in a project, then both "incoming connections" and "outgoing connections" should be enabled in the "Signing & Capabilities" settings of the project. The API is prevented from working unless these are enabled.