title: python urllib3 lambda Error: LocationParseError Failed to parse
body: <p>I'm using urllib3 library in Lambda and python3 code that fetches the webhook url of MSTeams from AWS Secret Manager and sends a http post request to publish a notification.</p>
  <p>My webhook url starts with https and looks like this &quot;https://outlook.office.com/webhook/.......&quot;. On executing the lambda function, I get an error as shown below <code>LocationParseError Failed to parse:</code></p>
  <p>Code</p>
  <pre><code>import urllib3 
  
  http = urllib3.PoolManager() 
  
  MSTEAMS_WEBHOOK_SECRET_NAME = os.getenv('MSTEAMS_WEBHOOK_SECRET_NAME') 
  HOOK_URL = get_secret(MSTEAMS_WEBHOOK_SECRET_NAME,&quot;eu-west-1&quot;) 
  
  def get_secret(secret_name, region_name):
  
      # Create a Secrets Manager client
      session = boto3.session.Session()
      client = session.client(
          service_name='secretsmanager',
          region_name=region_name
      )
          get_secret_value_response = client.get_secret_value(
              SecretId=secret_name,
              VersionStage=&quot;AWSCURRENT&quot;
          )
          if 'SecretString' in get_secret_value_response:
              secret = get_secret_value_response['SecretString']
              return secret
          else:
              decoded_binary_secret = base64.b64decode(get_secret_value_response['SecretBinary'])
              return decoded_binary_secret
  
  
  def lambda_handler(event, context):
   message = {
        &quot;@context&quot;: &quot;https://schema.org/extensions&quot;,
        &quot;@type&quot;: &quot;MessageCard&quot;,
        &quot;themeColor&quot;: data[&quot;colour&quot;],
        &quot;title&quot;: title,
        &quot;text&quot;: &quot;accountId:\n&quot;  + account_id + &quot; &lt;br/&gt;\n&quot; 
      }
   
      webhook_encoded_body = json.dumps(message).encode('utf-8')
      response = http.request('POST',HOOK_URL, body=webhook_encoded_body)
  </code></pre>
  <p>errorMessage</p>
  <pre><code>{
    &quot;errorMessage&quot;: &quot;Failed to parse: {\&quot;msteams-secret\&quot;:\&quot;https://outlook.office.com/webhook/dxxxxxx@d779xxxxx-xxxxxx/IncomingWebhook/axxxxxx5/ca746326-bxxx-4xxx-8x-xxxxx\&quot;}&quot;,
    &quot;errorType&quot;: &quot;LocationParseError&quot;,
    &quot;stackTrace&quot;: [
      [
        &quot;/var/task/lambda_function.py&quot;,
        145,
        &quot;lambda_handler&quot;,
        &quot;resp = http.request('POST',HOOK_URL, body=webhook_encoded_body)&quot;
      ],
      [
        &quot;/var/runtime/urllib3/request.py&quot;,
        80,
        &quot;request&quot;,
        &quot;method, url, fields=fields, headers=headers, **urlopen_kw&quot;
      ],
      [
        &quot;/var/runtime/urllib3/request.py&quot;,
        171,
        &quot;request_encode_body&quot;,
        &quot;return self.urlopen(method, url, **extra_kw)&quot;
      ],
      [
        &quot;/var/runtime/urllib3/poolmanager.py&quot;,
        324,
        &quot;urlopen&quot;,
        &quot;u = parse_url(url)&quot;
      ],
      [
        &quot;/var/runtime/urllib3/util/url.py&quot;,
        392,
        &quot;parse_url&quot;,
        &quot;return six.raise_from(LocationParseError(source_url), None)&quot;
      ],
      [
        &quot;&lt;string&gt;&quot;,
        3,
        &quot;raise_from&quot;,
        &quot;&quot;
      ]
    ]
  }
  </code></pre>