BookmarkSubscribeRSS Feed
ashishj816
Quartz | Level 8

Hi,

 

I am getting the below error when I am trying to connect to SAS using python.

 

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>405 Method Not Allowed</title>
</head><body>
<h1>Method Not Allowed</h1>
<p>The requested method PUT is not allowed for the URL /cas/sessions.</p>
</body></html>

JSONDecodeError                           Traceback (most recent call last)
D:\Learn\lib\site-packages\swat\cas\rest\connection.py in _connect(self, session, locale, wait_until_idle)
    384                     txt = a2u(res.text, 'utf-8')
--> 385                     out = json.loads(txt, strict=False)
    386                 except Exception:

D:\Learn\lib\json\__init__.py in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    369         kw['parse_constant'] = parse_constant
--> 370     return cls(**kw).decode(s)

D:\Learn\lib\json\decoder.py in decode(self, s, _w)
    336         """
--> 337         obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    338         end = _w(s, end).end()

D:\Learn\lib\json\decoder.py in raw_decode(self, s, idx)
    354         except StopIteration as err:
--> 355             raise JSONDecodeError("Expecting value", s, err.value) from None
    356         return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

SWATError                                 Traceback (most recent call last)
<ipython-input-17-3764ecc0579f> in <module>
D:\Learn\lib\site-packages\swat\cas\connection.py in __init__(self, hostname, port, username, password, session, locale, nworkers, name, authinfo, protocol, path, ssl_ca_list, **kwargs)
    424                 params = (hostname, port, username, password, soptions, self._sw_error)
    425                 if protocol in ['http', 'https']:
--> 426                     self._sw_connection = rest.REST_CASConnection(*params)
    427                 else:
    428                     self._sw_connection = clib.SW_CASConnection(*params)

D:\Learn\lib\site-packages\swat\cas\rest\connection.py in __init__(self, hostname, port, username, password, soptions, error)
    308         })
    309 
--> 310         self._connect(session=session, locale=locale, wait_until_idle=False)
    311 
    312     def _connect(self, session=None, locale=None, wait_until_idle=True):

D:\Learn\lib\site-packages\swat\cas\rest\connection.py in _connect(self, session, locale, wait_until_idle)
    416 
    417             except Exception as exc:
--> 418                 raise SWATError(str(exc))
    419 
    420             except SWATError:

SWATError: Expecting value: line 1 column 1 (char 0)

 conn = swat.CAS("https://myserver.company.com",443,"user","password") this is what  I was trying to execute in python 

 

 

 

 

 

 

1 REPLY 1
Hari_Mummidi
Fluorite | Level 6

I think the default port is 5570 for CAS Server and you are using 443 in the python code, 443 is used if you are using HTTPS API calls

import swat
s = swat.CAS("cloud.example.com", 5570,user,pwd)

For HTTPS end point 

s = swat.CAS("https://webserver.example.com/cas-shared-default-http/",username=user,passsword=pwd)

Make Sure you have the trusted cacerts imported to local machine from the server.

More details can be found from 

https://go.documentation.sas.com/api/docsets/caspg3/3.4/content/caspg3.pdf

sas-innovate-2024.png

📢

ANNOUNCEMENT

The early bird rate has been extended! Register by March 18 for just $695 - $100 off the standard rate.

 

Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 

 

Register now!

Discussion stats
  • 1 reply
  • 621 views
  • 1 like
  • 2 in conversation