Issue with CapacitorHttp on iOS

I recently switched HTTP calls from the Cordova plugin to CapacitorHttp, and having sporadic issues with IOS (only).

Using the latest Ionic 7.2.2 and Capacitor 5.2.2. Running against a back-end web service in the cloud using “https”.

Everything works fine for Android, and in the Web App – but iOS is failing every other call. Here is what I see in my logs for iOS:

Successful call to API, but just before call is made:
[NSURLSession sharedSession] may not be invalidated

Unsuccessful call to API, after it has failed:
(NSURLErrorDomain error -1000.)",“message”:“The operation couldn’t be completed”

The above cycle repeats consistently with the pattern as … works, fails, works, fails, etc…

For the life of me I cannot find anything online that indicates what these errors are and how they pertain to my usage of CapacitorHttp. There must be some specific configuration needed for iOS – any ideas? Who else has this working and care to share what your code looks like? I am following the tutorial/examples…


I have the same issue, did you have a chance to solve it ?

could you please told me ?


I have not found a solution yet. I suspect that some sort of initialization of the HTTP session is occurring (or needs to occur) within the plugin for Apple/iOS. However somebody must have this working so hopefully they can point the way

Could you please post here if you find any solution?

Figured it out, though I’m not sure why it worked 50% of the time without this for iOS, nor why it always worked for Android/web.

The line of code I was missing is simply this:

url = encodeURI(url);

Annoyingly, I had this line for the Cordova plugin I used before Capacitor. Anyway, I hope this helps someone out there who may run into the same issue.