<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: &amp;quot;ValueError: scheme https is invalid&amp;quot; when trying to connect to engine api via proxy in Integration, Extension &amp; APIs</title>
    <link>https://community.qlik.com/t5/Integration-Extension-APIs/quot-ValueError-scheme-https-is-invalid-quot-when-trying-to/m-p/2477987#M21152</link>
    <description>&lt;P&gt;ok, I tried on my end and if you are trying to connect with certificates, you have to connect directly to 4747 port (check if the port is open from Qlik Server).&lt;/P&gt;
&lt;P&gt;Furthermore I have changed the way you are passing the certs. Below code works for me.&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;from websocket import create_connection
import json
import ssl

host = 'QMI-QS-f716'
cert_path = './certs'
user_directory, user_id = "QMI-QS-f716","qlik"

url = "wss://{0}:4747/app/".format(host)
certs = ({"ca_certs": f'{cert_path}/root.pem',
            "certfile": f'{cert_path}/client.pem',
            "keyfile": f'{cert_path}/client_key.pem',
            "cert_reqs":ssl.CERT_REQUIRED,
            "server_side": False
            })
ssl.match_hostname = lambda cert, hostname: True
ws = create_connection(url, sslopt=certs,header={'X-Qlik-User: UserDirectory={0}; UserId={1}'.format(user_directory, user_id)})

ws.send(json.dumps({
        "handle": -1,
        "method": "GetDocList",
        "params": [],
        "outKey": -1,
        "id": 1
}))

result = ws.recv()

while result:
    result=ws.recv()
    y = json.loads(result)
    print(y)

ws.close()&lt;/LI-CODE&gt;</description>
    <pubDate>Mon, 26 Aug 2024 10:32:44 GMT</pubDate>
    <dc:creator>alex_colombo</dc:creator>
    <dc:date>2024-08-26T10:32:44Z</dc:date>
    <item>
      <title>"ValueError: scheme https is invalid" when trying to connect to engine api via proxy</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/quot-ValueError-scheme-https-is-invalid-quot-when-trying-to/m-p/2477618#M21143</link>
      <description>&lt;P&gt;Hi, I'm trying to connect to the engine api of qlik sense enterprise via a virtual proxy and have primarily been following&amp;nbsp;&lt;A href="https://community.qlik.com/t5/Official-Support-Articles/Qlik-Sense-call-Qlik-Sense-Engine-API-with-Python/ta-p/1716089" target="_blank"&gt;https://community.qlik.com/t5/Official-Support-Articles/Qlik-Sense-call-Qlik-Sense-Engine-API-with-Python/ta-p/1716089&lt;/A&gt;&amp;nbsp;and&amp;nbsp;&lt;A href="https://community.qlik.com/t5/Integration-Extension-APIs/Can-t-perform-a-simple-Engine-API-call-to-an-app-using-python/m-p/2103434/highlight/true#M18972" target="_blank"&gt;https://community.qlik.com/t5/Integration-Extension-APIs/Can-t-perform-a-simple-Engine-API-call-to-an-app-using-python/m-p/2103434/highlight/true#M18972&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;This is the current code I have, which is failing at the connection creation with&amp;nbsp;"ValueError: scheme https is invalid". I have tried ws instead of wss, but this just causes the call to hang, and I've tried simply&amp;nbsp;&lt;SPAN&gt;sslopt&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;SPAN&gt;"cert_reqs"&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;ssl&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;CERT_NONE&lt;/SPAN&gt;&lt;SPAN&gt;}, but I get the same value error.&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;import websocket
import ssl
import json

userdirectory = '&amp;lt;directory&amp;gt;'
userid = '&amp;lt;user&amp;gt;'
cert_path = '/path/to/cert-folder'
certs = ({"ca_certs":f'{cert_path}/root.pem',
                      "certfile": f'{cert_path}/client.pem',
                      "keyfile": f'{cert_path}/client_key.pem',
                      "cert_reqs": ssl.CERT_NONE,
                      "server_side": False})
header_user = {'header_user': f'{userdirectory}\\{userid}'}

ssl_context = ssl.create_default_context(purpose=ssl.Purpose.CLIENT_AUTH)
    ssl_context.load_cert_chain(certfile=f'{cert_path}/client.pem', keyfile=f'{cert_path}/client_key.pem')

ws = websocket.create_connection(
        "wss://&amp;lt;domain&amp;gt;/&amp;lt;proxy-prefix&amp;gt;/app", 
        sslopt={"cert_reqs": ssl.CERT_NONE; "ssl_context": ssl_context},
        header=header_user
    )

print("Sending message")
ws.send(json.dumps({
        "handle": -1,
        "method": "GetDocList",
        "params": [],
        "outKey": -1,
        "id": 1
}))

result = ws.recv()
print(result)


ws.close()&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2024 21:34:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/quot-ValueError-scheme-https-is-invalid-quot-when-trying-to/m-p/2477618#M21143</guid>
      <dc:creator>jjb427</dc:creator>
      <dc:date>2024-08-22T21:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: "ValueError: scheme https is invalid" when trying to connect to engine api via proxy</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/quot-ValueError-scheme-https-is-invalid-quot-when-trying-to/m-p/2477732#M21147</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/256327"&gt;@jjb427&lt;/a&gt;&amp;nbsp;when you are passing a user in the headers you should use this syntax&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;headers: {
	'X-Qlik-User': `UserDirectory=${encodeURIComponent(config.userDirectory)}; UserId=${encodeURIComponent(config.userId)}`,
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;Please fix this and try again.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Aug 2024 12:14:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/quot-ValueError-scheme-https-is-invalid-quot-when-trying-to/m-p/2477732#M21147</guid>
      <dc:creator>alex_colombo</dc:creator>
      <dc:date>2024-08-23T12:14:36Z</dc:date>
    </item>
    <item>
      <title>Re: "ValueError: scheme https is invalid" when trying to connect to engine api via proxy</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/quot-ValueError-scheme-https-is-invalid-quot-when-trying-to/m-p/2477809#M21150</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/145804"&gt;@alex_colombo&lt;/a&gt;,&amp;nbsp;I tried that header format (python code below), but I am continuing to get the "scheme https is invalid" error&lt;/P&gt;
&lt;PRE class="language-python"&gt;&lt;CODE&gt;encoded_user_directory = urllib.parse.quote(user_directory)
encoded_user_id = urllib.parse.quote(user_id)
x_qlik_user_header = f"UserDirectory={encoded_user_directory}; UserId={encoded_user_id}"

headers = [
    f"X-Qlik-User: {x_qlik_user_header}"
]&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Aug 2024 20:03:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/quot-ValueError-scheme-https-is-invalid-quot-when-trying-to/m-p/2477809#M21150</guid>
      <dc:creator>jjb427</dc:creator>
      <dc:date>2024-08-23T20:03:48Z</dc:date>
    </item>
    <item>
      <title>Re: "ValueError: scheme https is invalid" when trying to connect to engine api via proxy</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/quot-ValueError-scheme-https-is-invalid-quot-when-trying-to/m-p/2477987#M21152</link>
      <description>&lt;P&gt;ok, I tried on my end and if you are trying to connect with certificates, you have to connect directly to 4747 port (check if the port is open from Qlik Server).&lt;/P&gt;
&lt;P&gt;Furthermore I have changed the way you are passing the certs. Below code works for me.&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;from websocket import create_connection
import json
import ssl

host = 'QMI-QS-f716'
cert_path = './certs'
user_directory, user_id = "QMI-QS-f716","qlik"

url = "wss://{0}:4747/app/".format(host)
certs = ({"ca_certs": f'{cert_path}/root.pem',
            "certfile": f'{cert_path}/client.pem',
            "keyfile": f'{cert_path}/client_key.pem',
            "cert_reqs":ssl.CERT_REQUIRED,
            "server_side": False
            })
ssl.match_hostname = lambda cert, hostname: True
ws = create_connection(url, sslopt=certs,header={'X-Qlik-User: UserDirectory={0}; UserId={1}'.format(user_directory, user_id)})

ws.send(json.dumps({
        "handle": -1,
        "method": "GetDocList",
        "params": [],
        "outKey": -1,
        "id": 1
}))

result = ws.recv()

while result:
    result=ws.recv()
    y = json.loads(result)
    print(y)

ws.close()&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 26 Aug 2024 10:32:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/quot-ValueError-scheme-https-is-invalid-quot-when-trying-to/m-p/2477987#M21152</guid>
      <dc:creator>alex_colombo</dc:creator>
      <dc:date>2024-08-26T10:32:44Z</dc:date>
    </item>
    <item>
      <title>Re: "ValueError: scheme https is invalid" when trying to connect to engine api via proxy</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/quot-ValueError-scheme-https-is-invalid-quot-when-trying-to/m-p/2478040#M21153</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/145804"&gt;@alex_colombo&lt;/a&gt;, thank you so much for your help with this. We would actually like to authenticate using the virtual proxy as opposed to certificates, but I've got this working with the following code:&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;import websocket
import ssl
import json

user_directory, user_id = "&amp;lt;user_directory&amp;gt;","&amp;lt;user_id&amp;gt;"
header_user = {'header_user': f'{user_directory}\\{user_id}'}

ws = websocket.create_connection("wss://&amp;lt;host&amp;gt;/&amp;lt;proxy-prefix&amp;gt;/app/", sslopt={"cert_reqs": ssl.CERT_NONE},header=header_user)

ws.send(json.dumps({
	"handle": -1,
	"method": "GetDocList",
	"params": [],
	"outKey": -1,
	"id": 1
}))

result = ws.recv()

while result:
    result=ws.recv()
    y = json.loads(result)
    print(y)

ws.close()&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 26 Aug 2024 14:37:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/quot-ValueError-scheme-https-is-invalid-quot-when-trying-to/m-p/2478040#M21153</guid>
      <dc:creator>jjb427</dc:creator>
      <dc:date>2024-08-26T14:37:27Z</dc:date>
    </item>
  </channel>
</rss>

