BookmarkSubscribeRSS Feed
Quartz | Level 8



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


<title>405 Method Not Allowed</title>
<h1>Method Not Allowed</h1>
<p>The requested method PUT is not allowed for the URL /cas/sessions.</p>

JSONDecodeError                           Traceback (most recent call last)
D:\Learn\lib\site-packages\swat\cas\rest\ 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\ 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\ 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\ 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\ 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\ in __init__(self, hostname, port, username, password, soptions, error)
    308         })
--> 310         self._connect(session=session, locale=locale, wait_until_idle=False)
    312     def _connect(self, session=None, locale=None, wait_until_idle=True):

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

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

 conn = swat.CAS("",443,"user","password") this is what  I was trying to execute in python 







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("", 5570,user,pwd)

For HTTPS end point 

s = swat.CAS("",username=user,passsword=pwd)

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

More details can be found from


Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.


Register now!

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