You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unable to add existing site column to content typ (ct.field_links.add()) #942
field_links = ct_target.field_links.add(field_target).execute_query()
`
The field_target is found and of type 'office365.sharepoint.fields.field.Field'.
The error is:
`Traceback (most recent call last):
File "/home/joe/.local/lib/python3.10/site-packages/office365/runtime/client_request.py", line 37, in execute_query
response = self.execute_request_direct(request)
File "/home/joe/.local/lib/python3.10/site-packages/office365/runtime/client_request.py", line 101, in execute_request_direct
response.raise_for_status()
File "/usr/lib/python3/dist-packages/requests/models.py", line 943, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://joe.sharepoint.com/sites/Joe_PROD/_api/Web/ContentTypes('0x0100DBB1EA60214E52428BCC389XXXSSSAAA')/FieldLinks
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/joe/reporting/sharepoint_list_mgmt/sp_site_config_reproduce.py", line 189, in
field_link = ct_target.field_links.add(field_target).execute_query()
File "/home/joe/.local/lib/python3.10/site-packages/office365/runtime/client_object.py", line 55, in execute_query
self.context.execute_query()
File "/home/joe/.local/lib/python3.10/site-packages/office365/runtime/client_runtime_context.py", line 173, in execute_query
self.pending_request().execute_query(qry)
File "/home/joe/.local/lib/python3.10/site-packages/office365/runtime/client_request.py", line 41, in execute_query
raise ClientRequestException(*e.args, response=e.response)
office365.runtime.client_request_exception.ClientRequestException: ('-2147024809, System.ArgumentException', "Die Spalte 'Absender' ist nicht vorhanden. Möglicherweise wurde sie von einem anderen Benutzer gelöscht. https://joe.sharepoint.com/sites/Joe_PROD ", "400 Client Error: Bad Request for url: https://joe.sharepoint.com/sites/Joe_PROD/_api/Web/ContentTypes('0x0100DBB1EA60214E52428BCC389XXXSSSAAA')/FieldLinks")
`
Not a library defect — this is a documented SharePoint REST limitation. FieldLinkCollection.add() already sends the payload Microsoft documents for this endpoint: an SP.FieldLink object carrying FieldInternalName (see the "REST resource endpoint" section of SP.FieldLinkCollection.add). The server accepts it and then fails to resolve the column, which is the documented behavior:
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.
The failing URL is /_api/Web/ContentTypes('0x...')/FieldLinks, i.e. a site content type, so REST cannot link a site column to it. The same limitation is still present in SharePoint Online (SharePoint/sp-dev-docs#10489).
Workarounds:
List content type: add the column to the list first (e.g. via the UI's "Add from existing site columns" or list.fields.add_field_as_xml(...)), then link it with list.content_types.get_by_name(...).field_links.add(...).
Site content type: REST cannot do it — use CSOM/PnP (Add-PnPFieldToContentType) or PowerShell.
Since this is a server-side limit rather than something the REST client can change, closing as not planned.
Activity
tuesdayMike commentedon Feb 20, 2025
I tried switching to plain vanilla http requests (SP Rest API) but âlways get to the 404 point. This limitations seems to be the problem:
Site Columns cannot be added to a content type using the REST service.
Source: https://learn.microsoft.com/en-us/previous-versions/office/sharepoint-visio/jj245869(v=office.15)
office365-maintainer commentedon Oct 3, 2026
Not a library defect — this is a documented SharePoint REST limitation.
FieldLinkCollection.add()already sends the payload Microsoft documents for this endpoint: anSP.FieldLinkobject carryingFieldInternalName(see the "REST resource endpoint" section of SP.FieldLinkCollection.add). The server accepts it and then fails to resolve the column, which is the documented behavior:The failing URL is
/_api/Web/ContentTypes('0x...')/FieldLinks, i.e. a site content type, so REST cannot link a site column to it. The same limitation is still present in SharePoint Online (SharePoint/sp-dev-docs#10489).Workarounds:
list.fields.add_field_as_xml(...)), then link it withlist.content_types.get_by_name(...).field_links.add(...).Add-PnPFieldToContentType) or PowerShell.Since this is a server-side limit rather than something the REST client can change, closing as not planned.