InvalidSchema("No connection adapters were found for '%s'" % url)

```
raise InvalidSchema("No connection adapters were found for '%s'" % url)
requests.exceptions.InvalidSchema: <exception str() failed>
```

Getting the above error when I do:

```
headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36'}
r = requests.get(page_url, headers=headers)
```

Where page_url is the URL of the webpage I'm requesting. I've confirmed the URL is correct and stored in page_url properly; the issue appears to be the fact that I'm grabbing the URL from a file. Replacing page_url with the actual URL removes the error. Is there some issue with using a URL that's stored in a variable rather than hardcoding it or something?

It'd be really helpful to see the value of "page_url". Also are redirects occurring after visiting that url?

Hi @Blah237, this is almost certainly a parsing issue in how you’re reading the url. If the scheme for the url isn’t http or https, you’ll need to provide a custom adapter. If it is one of the two we support, I’d ensure you aren’t leaving extra white space on the url or accidentally removing a leading character.

Since there isn’t evidence of a bug here, I’m going to close this out. If you find anything conclusive, please feel free to reopen. Thanks!

Apologies @Blah237, rereading the exception, whatever you’re passing as the url is an object which either hasn’t implemented `__repr__`/`__str__` or is raising an exception when executing its str method. We only support strings in the Requests api, so I’d verify the object type of what you’re passing to the url param.

@nateprewitt No worries, thank you for the fast response and the help! When I print out the type directly before, I get `<class 'str'>`. I'm originally grabbing the url from a csv (also tried grabbing it from a text file which caused the same issue), and then I'm casting it to a string right before `requests.get` is called.

I admit I am completely lost--the type appears to be correct, and I know the URL is valid because the code works when I copy and paste the URL as a string into it.

Looks like you're printing the `str` type?

```python
print(str)  # <class 'str'>

print(str('abc'))  # abc
```

@SethMichaelLarson Apologies, I misspoke. My code is as follows:

```
headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36'}

print(type(page_url))
r = requests.get(page_url.strip(), headers=headers)
```

Which prints `<class 'str'>` before giving me the error.

Well `Request.url` is just whatever was passed into `requests.get()` so whatever you're passing in can't be converted into a string? What is the value of page_url?

@Blah237 so the fact it’s getting to this exception shows that it’s at least string like because we call .lower() and .startswith() on it prior to raising this exception.

One thing I realized we haven’t gotten from you yet is the version of Requests you’re using. Can you please supply the info that was requested when the ticket was opened?

I’m still not sure if there’s a bug here but it doesn’t make sense looking at the code how we’d get here if this isn’t a valid string. Other exceptions should have triggered before we got here.

If you are able to provide the url privately, my email is listed in the project, or I have a keybase account (https://keybase.io/nateprewitt). If you aren’t able to do that, have you tried to reproduce this with a public url? That would be my next step for debugging to determine if it’s the service (possibly redirects) or the file parsing code.

Apologies for the late reply--I unfortunately can't share the url, but the result remains the same no matter the url used (something like https://google.com doesn't even work). No redirects are taking place.

After playing around with it for a bit (and updating all my code for Python 3), the error is now this:

```
raise InvalidSchema("No connection adapters were found for '%s'" % url)
requests.exceptions.InvalidSchema: No connection adapters were found for 'https://google.com'
```
I'm using version 2.19.1.

Solved it! Reading from a csv file includes a character which appears at the beginning of files, `u'\ufeff'`. I had to manually remove the character with `page_url.replace(u'\ufeff', '')` to get it to work.


data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBwgHBgkIBwgKCgkLDRYPDQwMDRsUFRAWIB0iIiAdHx8kKDQsJCYxJx8fLT0tMTU3Ojo6Iys/RD84QzQ5OjcBCgoKDQwNGg8PGjclHyU3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3N//AABEIAIQAhAMBIgACEQEDEQH/xAAbAAEBAQEBAQEBAAAAAAAAAAAABgUEAwcCAf/EAEAQAAEDAgEGCggEBQUAAAAAAAEAAgMEEQUGEiFRsdETFBUiMTVBU3GTNFRhcnOBgpIyM5GhFiOyweFCQ1JiY//EABoBAQADAQEBAAAAAAAAAAAAAAABAgMFBAb/xAAsEQACAgECAwYGAwAAAAAAAAAAAQIDEQQxEhMhBRRRU3HRFSIyMzRhQUJS/9oADAMBAAIR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JYzZ7DcFVdLlBRTRDjX8uS2kFtx8l0dLKE6ZUyeDSOGsMkfmE+YVryzhPes8s7k5YwnvmeWdynuNXmongXiRXzCfMK15ZwnvWeWdycsYT3zPLO5O41+YhwLxIrRrT5hWvLOE96zyzuTljCe+Z5Z3J3GvzUOBeJFaNYTRrCteWcJ71nlncnLOFd6zyzuTuVXmIcC8SOgYZJ42MBc4uAACrcpzbCCDoJe1fs41hbRdsrbjVGb7FP43ivKD2sjBbAzSAeknWrtVaamaU8uQwkjLREXKMwiIhAREQBERAEREJCIiAIiIAiIgCIiEBERAEREAREQBERAEREAREQBERAEREAREQBERAEREB//9k=

this is image url...  I am getting this error "No connection adapters were found for" when I try to send request in python.
![2020-04-21_010854](https://user-images.githubusercontent.com/59928025/79767448-b2576500-836c-11ea-8e9d-7cba6d9d3179.jpg)


That is not an image url. This is the whole image encoded as base64. 
you cannot send a request to that url since it is not a resource the server is offering but rather encoded data that is already present locally.

to decode it you can use import base64 and decode the data. (everything after data:image/jpeg;base64,)

im not sure if there is a feature native to 'requests' that handles this.

i have this issue too. below is the code.
import os
import json 
import io
import requests 
import numpy as np
import tensorflow as tf
from PIL import Image
import matplotlib.pyplot as plt
import PIL


ASSETS_DIR = r"C:\Users\Sortol\Documents\adesoji-fastapi\assets"
TEST_IMAGES_DIR = r"C:\Users\Sortol\Documents\adesoji-fastapi\images"

classes = json.load(open(os.path.join(ASSETS_DIR,'categories.json')))
classes = {v:k for k,v in classes.items()}

URL = "/v1/models/flower-classification:predict"

def read_img_file(file) -> Image.Image:
    img = Image.open(io.BytesIO(file))
    if img.mode == "RGBA":
        img = img.convert("RGB")
    img = img.resize((224,224), Image.ANTIALIAS)
    img = tf.expand_dims(np.asarray(img)/255, 0)
    return img

def load_img(img_path, show:bool=False):
  # img_path = random.choice(glob.glob(f"{DATASET_DIR}/test/{cls}/*.jpg"))
  img = PIL.Image.open(img_path)
  img = img.resize((224,224), PIL.Image.ANTIALIAS)
  if show:
    plt.imshow(img)
    plt.title('cls')
  img = tf.expand_dims(np.asarray(img)/255, 0)
  return img

def predict(img):
  headers = {
      "content-type" : "application/json"
  }
  data = json.dumps({
      "signature_name": "serving_default", "instances": img.numpy().tolist()
  })
  response = requests.post(URL, data=data, headers=headers)
  response_data = json.loads(response.text)['predictions'][0]
  confidence = np.max(response_data)
  predicted_class = classes[np.argmax(response_data)]
  return response_data,confidence,predicted_class

now i get this error below

C:\Users\Sortol\Documents\adesoji-fastapi\app>uvicorn main:app
2021-03-01 23:18:10.330558: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll
INFO:     Started server process [6912]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     127.0.0.1:54121 - "GET / HTTP/1.1" 404 Not Found
INFO:     127.0.0.1:54129 - "GET /docs HTTP/1.1" 200 OK
INFO:     127.0.0.1:54129 - "GET /openapi.json HTTP/1.1" 200 OK
2021-03-01 23:18:39.587847: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set
2021-03-01 23:18:39.596337: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library nvcuda.dll
2021-03-01 23:18:39.686352: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties: 
pciBusID: 0000:03:00.0 name: GeForce 840M computeCapability: 5.0
coreClock: 1.124GHz coreCount: 3 deviceMemorySize: 2.00GiB deviceMemoryBandwidth: 13.41GiB/s
2021-03-01 23:18:39.687791: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll
2021-03-01 23:18:39.782907: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublas64_11.dll
2021-03-01 23:18:39.783942: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublasLt64_11.dll
2021-03-01 23:18:39.832809: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cufft64_10.dll
2021-03-01 23:18:39.844951: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library curand64_10.dll
2021-03-01 23:18:39.939685: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusolver64_10.dll
2021-03-01 23:18:39.961540: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusparse64_11.dll
2021-03-01 23:18:39.965590: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudnn64_8.dll
2021-03-01 23:18:39.966611: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1862] Adding visible gpu devices: 0
2021-03-01 23:18:39.981739: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2021-03-01 23:18:39.985255: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties: 
pciBusID: 0000:03:00.0 name: GeForce 840M computeCapability: 5.0
coreClock: 1.124GHz coreCount: 3 deviceMemorySize: 2.00GiB deviceMemoryBandwidth: 13.41GiB/s
2021-03-01 23:18:39.987565: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll
2021-03-01 23:18:39.988770: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublas64_11.dll
2021-03-01 23:18:39.989115: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublasLt64_11.dll
2021-03-01 23:18:39.989445: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cufft64_10.dll
2021-03-01 23:18:39.989775: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library curand64_10.dll
2021-03-01 23:18:39.991063: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusolver64_10.dll
2021-03-01 23:18:39.991441: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusparse64_11.dll
2021-03-01 23:18:39.991842: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudnn64_8.dll
2021-03-01 23:18:39.993129: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1862] Adding visible gpu devices: 0
2021-03-01 23:18:43.086253: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1261] Device interconnect StreamExecutor with strength 1 edge matrix:
2021-03-01 23:18:43.088620: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1267]      0 
2021-03-01 23:18:43.089128: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1280] 0:   N
2021-03-01 23:18:43.107867: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1406] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 
1369 MB memory) -> physical GPU (device: 0, name: GeForce 840M, pci bus id: 0000:03:00.0, compute capability: 5.0)
2021-03-01 23:18:43.156687: I tensorflow/compiler/jit/xla_gpu_device.cc:99] Not creating XLA devices, tf_xla_enable_xla_devices not set
tf.Tensor(
[[[[0.64705882 0.65490196 0.48627451]
   [0.58823529 0.60392157 0.46666667]
   [0.54117647 0.56078431 0.42352941]
   ...
   [0.35686275 0.52941176 0.32941176]
   [0.20392157 0.34509804 0.23529412]
   [0.13333333 0.25882353 0.14117647]]

  [[0.6627451  0.69411765 0.51372549]
   [0.58431373 0.60784314 0.4627451 ]
   [0.50588235 0.50980392 0.4       ]
   ...
   [0.39607843 0.55294118 0.36470588]
   [0.15294118 0.29411765 0.18431373]
   [0.05098039 0.18823529 0.06666667]]

  [[0.61960784 0.64313725 0.50196078]
   [0.63921569 0.62745098 0.52156863]
   [0.57254902 0.51764706 0.47843137]
   ...
   [0.38039216 0.52156863 0.36862745]
   [0.16862745 0.30980392 0.21568627]
   [0.0745098  0.21960784 0.09411765]]

  ...

  [[0.32941176 0.48627451 0.33333333]
   [0.32941176 0.48627451 0.3254902 ]
   [0.31764706 0.50196078 0.32156863]
   ...
   [0.57254902 0.68235294 0.66666667]
   [0.23529412 0.34509804 0.36078431]
   [0.20784314 0.3254902  0.29411765]]

  [[0.36078431 0.48235294 0.3372549 ]
   [0.35686275 0.49019608 0.32941176]
   [0.34117647 0.52156863 0.3372549 ]
   ...
   [0.53333333 0.67058824 0.63137255]
   [0.22745098 0.36078431 0.37254902]
   [0.27843137 0.40392157 0.37647059]]

  [[0.34509804 0.4745098  0.32941176]
   [0.34117647 0.49019608 0.32156863]
   [0.33333333 0.52156863 0.3254902 ]
   ...
   [0.51764706 0.67843137 0.61568627]
   [0.25098039 0.40392157 0.40784314]
   [0.22352941 0.37647059 0.33333333]]]], shape=(1, 224, 224, 3), dtype=float64)
INFO:     127.0.0.1:54141 - "POST /predict HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "c:\users\sortol\anaconda3\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 396, in run_asgi
    result = await app(self.scope, self.receive, self.send)
  File "c:\users\sortol\anaconda3\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 45, in __call__
    return await self.app(scope, receive, send)
  File "c:\users\sortol\anaconda3\lib\site-packages\fastapi\applications.py", line 199, in __call__
    await super().__call__(scope, receive, send)
  File "c:\users\sortol\anaconda3\lib\site-packages\starlette\applications.py", line 111, in __call__
    await self.middleware_stack(scope, receive, send)
  File "c:\users\sortol\anaconda3\lib\site-packages\starlette\middleware\errors.py", line 181, in __call__
    raise exc from None
  File "c:\users\sortol\anaconda3\lib\site-packages\starlette\middleware\errors.py", line 159, in __call__
    await self.app(scope, receive, _send)
  File "c:\users\sortol\anaconda3\lib\site-packages\starlette\exceptions.py", line 82, in __call__
    raise exc from None
  File "c:\users\sortol\anaconda3\lib\site-packages\starlette\exceptions.py", line 71, in __call__
    await self.app(scope, receive, sender)
  File "c:\users\sortol\anaconda3\lib\site-packages\starlette\routing.py", line 566, in __call__
    await route.handle(scope, receive, send)
  File "c:\users\sortol\anaconda3\lib\site-packages\starlette\routing.py", line 227, in handle
    await self.app(scope, receive, send)
  File "c:\users\sortol\anaconda3\lib\site-packages\starlette\routing.py", line 41, in app
    response = await func(request)
  File "c:\users\sortol\anaconda3\lib\site-packages\fastapi\routing.py", line 201, in app
    raw_response = await run_endpoint_function(
  File "c:\users\sortol\anaconda3\lib\site-packages\fastapi\routing.py", line 148, in run_endpoint_function
    return await dependant.call(**values)
  File ".\main.py", line 21, in predict_image
    predictions = predict(flower_img)
  File ".\helpers.py", line 46, in predict
    response = requests.post(URL, data=data, headers=headers)
  File "c:\users\sortol\anaconda3\lib\site-packages\requests\api.py", line 119, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "c:\users\sortol\anaconda3\lib\site-packages\requests\api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "c:\users\sortol\anaconda3\lib\site-packages\requests\sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "c:\users\sortol\anaconda3\lib\site-packages\requests\sessions.py", line 637, in send
    adapter = self.get_adapter(url=request.url)
  File "c:\users\sortol\anaconda3\lib\site-packages\requests\sessions.py", line 730, in get_adapter
    raise InvalidSchema("No connection adapters were found for {!r}".format(url))
requests.exceptions.InvalidSchema: No connection adapters were found for '/v1/models/flower-classification:predict'