繁体   English   中英

SharePoint 2013-使用REST API将网站栏与内容类型相关联

[英]SharePoint 2013 - Associating Site Columns With Content Types Using the REST API

我正在尝试使用REST API以编程方式创建网站栏和内容类型。 一切正常,直到我尝试将网站列与内容类型相关联。

至此,在我的代码中,网站列和内容类型已经存在...

我正在将POST发送到以下URL ...

http://mydevmachine/sites/claimsreports/_api/web/ContentTypes('0x01003E9D5AD94A5DCD46876B7BFFCEA9B60C')/FieldLinks

这是我在请求正文中发送的信息...

{
  "__metadata": {
    "type": "SP.FieldLink"
  },
  "Id": "9400d057-ba2c-4ab4-9ce0-671b858fd849",
  "Name": "BusinessCategory",
  "Hidden": false,
  "Required": false
}

这是我得到回应的错误...

{"error":{"code":"-2147467261, System.ArgumentNullException","message":{"lang":"en-US","value":"Value cannot be null.\r\nParameter name: parameters"}}}

我尝试了其他几种选择,但均未成功。 例如,我尝试使用“ __metadata”:{“ type”:“ SP.FieldLinkCreationInformation”},但是我尝试使用__metadata类型进行的所有操作都会导致此错误...

{"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"A type named 'SP.FieldLinkCreationInformation' could not be resolved by the model. When a model is available, each type name must resolve to a valid type."}}}

听起来SharePoint告诉我此“类型”无效。 SharePoint 2013似乎应该有这种可能,因为该文档似乎暗示它可能...

文件

如果有人有任何想法,我将非常乐意为您提供建议。 谢谢!

根据文档,我会尝试:

端点(注意最后的/add ):

http://mydevmachine/sites/claimsreports/_api/web/ContentTypes('0x01003E9D5AD94A5DCD46876B7BFFCEA9B60C')/FieldLinks/add

正文(将您的属性包装在parameters属性中):

{"parameters":
{
"__metadata": {"type": "SP.FieldLink"},
"Id": "9400d057-ba2c-4ab4-9ce0-671b858fd849",
"Name": "BusinessCategory",
"Hidden": false,
"Required": false
}
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM