无法使用 confluence 对象调用方法:-“'NoneType' 对象不可订阅”
Can't call the methods using confluence objects:- "'NoneType' object is not subscriptable"
当我尝试创建 atlassian-confluence 的登录名时,当我尝试通过传递用户名 (email_id) 和 API 令牌密码来创建对象时,出现错误 'NoneType' 对象不可订阅。
我尝试使用 curl 使用相同的用户电子邮件 ID 和密码访问 url,我得到了如下有效响应:-
curl -v https://XXXXXXX.atlassian.net --user arun.kumar@something.com:xxxxxxxxxxxxxxxxxxxx
* Rebuilt URL to: https://projectcyclone.atlassian.net/
* Trying xx.xx.xx.xx...
* TCP_NODELAY set
* Connected to XXXXXXXX.atlassian.net (xx.xx.xx.xx) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
* Server certificate:
* subject: C=US; ST=California; L=San Francisco; O=Atlassian Network (easy handle 0x7f90af808400)
> GET / HTTP/2
> Host: XXXXXXXXXXX.atlassian.net
> Authorization: Basic YXJ1bi5rdW1hckB2aW9vaC5jb206VmYzYkRZUlRTR1I5ZHB6T3BqV3NENDNG
> User-Agent: curl/7.54.0
> Accept: */*
但是当我尝试使用我的凭据创建对象时,我无法使用该对象调用方法。
confluence = Confluence(
url="https://XXXXXX.atlassian.net",
username="arun.kumar@something.com",
password="xxxxxxxxx")
try:
confluence.get_page_by_title("My space","MyPage")
except Exception as e:
print(e)
我收到以下错误:
'NoneType' object is not subscriptable.
完整追溯:
Traceback (most recent call last): File
"/Users/k.arunkumar/confluence/py/confluence.py", line 26, in
myconfluence confluence.get_page_by_title("MY Space","My Page") File
"/Users/k.arunkumar/confluence/lib/python3.6/site-packages/atlassian/confluence.py",
line 128, in get_page_by_title return (self.get(url, params=params) or
{}).get('results')[0] TypeError: 'NoneType' object is not
subscriptable
行 (self.get(url, params=params) or {}).get('results')[0]
允许这种情况:
self.get(url, params=params)
returnsNone
,因为url
恰好是一个不存在的key
- 在这种情况下,
(self.get(url, params=params) or {})
returns {}
(一个空 dict
)
- 这个空字典没有
results
键(或任何其他键),所以 {}.get('results')
是 None
...
- 并试图调用
None[0]
导致你的错误。
当我尝试创建 atlassian-confluence 的登录名时,当我尝试通过传递用户名 (email_id) 和 API 令牌密码来创建对象时,出现错误 'NoneType' 对象不可订阅。
我尝试使用 curl 使用相同的用户电子邮件 ID 和密码访问 url,我得到了如下有效响应:-
curl -v https://XXXXXXX.atlassian.net --user arun.kumar@something.com:xxxxxxxxxxxxxxxxxxxx
* Rebuilt URL to: https://projectcyclone.atlassian.net/
* Trying xx.xx.xx.xx...
* TCP_NODELAY set
* Connected to XXXXXXXX.atlassian.net (xx.xx.xx.xx) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
* Server certificate:
* subject: C=US; ST=California; L=San Francisco; O=Atlassian Network (easy handle 0x7f90af808400)
> GET / HTTP/2
> Host: XXXXXXXXXXX.atlassian.net
> Authorization: Basic YXJ1bi5rdW1hckB2aW9vaC5jb206VmYzYkRZUlRTR1I5ZHB6T3BqV3NENDNG
> User-Agent: curl/7.54.0
> Accept: */*
但是当我尝试使用我的凭据创建对象时,我无法使用该对象调用方法。
confluence = Confluence(
url="https://XXXXXX.atlassian.net",
username="arun.kumar@something.com",
password="xxxxxxxxx")
try:
confluence.get_page_by_title("My space","MyPage")
except Exception as e:
print(e)
我收到以下错误:
'NoneType' object is not subscriptable.
完整追溯:
Traceback (most recent call last): File "/Users/k.arunkumar/confluence/py/confluence.py", line 26, in myconfluence confluence.get_page_by_title("MY Space","My Page") File "/Users/k.arunkumar/confluence/lib/python3.6/site-packages/atlassian/confluence.py", line 128, in get_page_by_title return (self.get(url, params=params) or {}).get('results')[0] TypeError: 'NoneType' object is not subscriptable
行 (self.get(url, params=params) or {}).get('results')[0]
允许这种情况:
self.get(url, params=params)
returnsNone
,因为url
恰好是一个不存在的key- 在这种情况下,
(self.get(url, params=params) or {})
returns{}
(一个空dict
) - 这个空字典没有
results
键(或任何其他键),所以{}.get('results')
是None
... - 并试图调用
None[0]
导致你的错误。