11

I'm trying to create a ContentType with FieldLinks using REST only (no SP.ClientContext) on SharePoint Online, but I'm not able to make it work.

Creating ContentType by POSTing to _api/Web/ContentTypes works fine by itself, the problem is FieldLinks.

  • 1
    I don't know if you've gotten this sorted out, but I think you have to daisy chain your way through by creating the content type, adding it to the collection, then updating the properties. msdn.microsoft.com/en-us/library/office/jj247038.aspx has them all listed. – Eric Alexander Jul 30 '15 at 18:50
  • @eirikb may I ask how you created the content type? I cannot find any information on the format of the data to POST to _api/Web/ContentTypes – claesv May 31 '16 at 9:13
  • 1
    @claesv I didn't. I ended up using JSOM. My app mixes both JSOM and REST. It's an Angular app so I wrap ClientContext in a promise, so they interchange fluently – eirikb May 31 '16 at 19:58
3

There are limitations on adding FieldLinks to a Content Type via REST. What you're attempting may not be possible at the moment. Here are the limitations:

  • Site Columns cannot be added to a content type using the REST service.
  • You can add a field to a site content type only if the field already exists on the parent content type.
  • You can add a field to a content type associated with a list only if the field already exists on the list. To add a completely new field to a list content type, you have to first add it to the list and then add it to the content type in a separate call to the REST service.

Taken from the documentation here:
https://msdn.microsoft.com/EN-US/library/office/jj245869.aspx#postsyntax

  • I'm not a big fan of "It's not possible", but the question has been out for some time now and your sources are solid. Thanks for the answer =) – eirikb Oct 31 '15 at 7:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.