gpt4 book ai didi

python - VersionOne.SDK.Python 创建故事时出现异常

转载 作者:太空宇宙 更新时间:2023-11-04 05:51:05 25 4
gpt4 key购买 nike

当我从 python 控制台调用 Create API 时,出现以下异常。

Traceback (most recent call last):
File "<stdin>", line 3, in <module>
File "C:\Python27\lib\v1pysdk\base_asset.py", line 44, in create
return Class._v1_v1meta.create_asset(Class._v1_asset_type_name, newdata)
File "C:\Python27\lib\v1pysdk\v1meta.py", line 128, in create_asset
new_asset_xml = self.server.create_asset(asset_type_name, update_doc)
File "C:\Python27\lib\v1pysdk\client.py", line 202, in create_asset
return self.get_xml(path, query=query, postdata=body)
File "C:\Python27\lib\v1pysdk\client.py", line 159, in get_xml
document = ElementTree.fromstring(body)
File "C:\Python27\lib\xml\etree\ElementTree.py", line 1281, in XML
parser.feed(text)
File "C:\Python27\lib\xml\etree\ElementTree.py", line 1623, in feed
self._raiseerror(v)
File "C:\Python27\lib\xml\etree\ElementTree.py", line 1487, in _raiseerror
raise err
xml.etree.ElementTree.ParseError: reference to invalid character number: line 7575, column 75

我在 Windows 上使用 Python2.7 运行它。这是我正在调用的 API

from v1pysdk import V1Meta

v1 = V1Meta(
address = 'www11.v1host.com',
instance = '<InstName>',
username = 'sbaid',
password = 'XXXXXX'
)

new_story = v1.Story.create(
Name = "Temp",
Scope = v1.Scope(321450)
)

v1.Scope(321450) 返回正确的项目名称,这意味着与版本 1 的 session 已正确建立。

这是仅有的两个强制参数,我可以使用 Web 界面使用这两个参数创建故事。

我还可以使用以下 REST 请求创建故事

网址 - https://www11.v1host.com/InstName/rest-1.v1/Data/Story

<Asset href="/<InstName>/rest-1.v1/New/Story">
<Attribute name="Name" act="set">Temp</Attribute>
<Relation name="Scope" act="set">
<Asset href="/<InstName>/rest-1.v1/Data/Scope/321450" idref="Scope:321450" />
</Relation>
</Asset>

最佳答案

还有一种更可靠的指定主机地址的替代方法。下面是一个示例,您可以针对公共(public) VersionOne SDK 测试实例进行尝试:

from v1pysdk import V1Meta

with V1Meta (
instance_url = 'https://www14.v1host.com/v1sdktesting',
username = 'admin',
password = 'admin'
) as v1:

new_story = v1.Story.create(
Name = "Temp Test for StackOverflow question",
Scope = v1.Scope(0)
)

fetched_story = v1.Story.where(Number=new_story.Number).first()
print fetched_story.Name

关于python - VersionOne.SDK.Python 创建故事时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30165782/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com