c# - Office365 REST API 查询添加超链接到列表?ClientServiceException 无法反序列化 Microsoft.SharePoint.SPFieldUrlValue 类型的数据
问题描述
我正在使用官方 Office 365 REST API 从列表中检索项目并将文件上传到 Sharepoint 和 Onedrive https://github.com/vgrem/Office365-REST-Python-Client/blob/master/examples/sharepoint/ listitem_operations.py
我目前正在尝试找到一种将附件包含到我的 Sharepoint 列表中的方法,而我正在尝试做的是将 Web URL 插入到我的列表中。但是,因为它是超链接类型,所以我收到一个异常错误提示Cannot deserialize data for type Microsoft.SharePoint.SPFieldUrlValue.', "500 Server Error: Internal Server Error for url:
我知道对于直接查询,它必须看起来像:
'__metadata': {'type': 'SP.Data.TasksListItem'},
{Url: 'http://google.com', Description: 'This is the description'}
有什么方法可以更正确地格式化 API 查询,以便我可以正确上传链接?或者有没有办法将项目作为文本上传,并在 Sharepoint 中显示为可点击的超链接?
编辑:只是为了澄清,这是用于更新列表项的功能:
def update_list_item(lst, row_id, column, value):
print("Update list item example...")
list_object = ctx.web.lists.get_by_title(lst)
item_id = str(row_id)
item = list_object.get_item_by_id(item_id)
item.set_property(column, str(value))
item.set_property('Key', 'Value')
item.update()
ctx.execute_query()
print("List item '{0}' has been updated.".format(item_id))
解决方案
尝试使用这个:
'__metadata': { 'type': 'SP.Data.TasksListItem' },
'Field':
{
'__metadata': { 'type': 'SP.FieldUrlValue' },
'Description': 'This is the description',
'Url': 'http://google.com'
}
推荐阅读
- haskell - 如何比较haskell中的自定义数据类型
- elasticsearch - 如何在 FOSElasticaBundle 中使用 indices_boost?
- mysql - Magento2 docker env,mysql端口方向错误
- android - SearchView 的提示文本颜色
- java - 如何将 JSON 数组解析为微调器
- java - 每秒执行方法 1 到 N 次
- python - 如何使用 python 调度创建一个作业任务,仅在白天从早上 6 点到晚上 10 点期间每 3 分钟运行一次
- android - 如何使用 MULTIPART/FORM-DATA 上传用户的个人资料图片?
- angular - 角服务空?
- java - 追加数组并替换 JSON 对象中的键