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
I have been successful adding fields to an existing list in Sharepoint with FieldCreationInformation with just the column name and column type but when I try using the choices parameter I am getting an HTTP Error.
I am using Office365-REST-Python-Client 2.5.3
Here is my code:
``
from office365.sharepoint.fields.creation_information import FieldCreationInformation
from office365.sharepoint.client_context import ClientContext
from office365.runtime.auth.client_credential import ClientCredential
Here is the error:
---------------------------------------------------------------------------
HTTPError Traceback (most recent call last)
~\AppData\Local\ESRI\conda\envs\clone-pro-2\lib\site-packages\office365\runtime\client_request.py in execute_query(self, query)
37 response = self.execute_request_direct(request)
---> 38 response.raise_for_status()
39 self.process_response(response, query)
~\AppData\Local\ESRI\conda\envs\clone-pro-2\lib\site-packages\requests\models.py in raise_for_status(self)
940 if http_error_msg:
--> 941 raise HTTPError(http_error_msg, response=self)
942
HTTPError: 400 Client Error: Bad Request for url: https://pge.sharepoint.com/sites/VMDataRequests15/_api/Web/lists/GetByTitle('SI%20Tracker%20-%20Dev')/Fields
During handling of the above exception, another exception occurred:
ClientRequestException Traceback (most recent call last)
<ipython-input-92-c3b89a42f9b7> in <module>
11 existing_list = ctx.web.lists.get_by_title("SI Tracker - Dev")
12 existing_list.fields.add(field_info)
---> 13 ctx.execute_query()
~\AppData\Local\ESRI\conda\envs\clone-pro-2\lib\site-packages\office365\runtime\client_runtime_context.py in execute_query(self)
183 while self.has_pending_request:
184 qry = self._get_next_query()
--> 185 self.pending_request().execute_query(qry)
186 return self
187
~\AppData\Local\ESRI\conda\envs\clone-pro-2\lib\site-packages\office365\runtime\client_request.py in execute_query(self, query)
40 self.afterExecute.notify(response)
41 except HTTPError as e:
---> 42 raise ClientRequestException(*e.args, response=e.response)
43
44 def execute_request_direct(self, request):
ClientRequestException: ('-1, Microsoft.SharePoint.Client.InvalidClientQueryException', "A node of type 'StartArray' was read from the JSON reader when trying to read a value of a property; however, a 'PrimitiveValue' or 'StartObject' node was expected.", "400 Client Error: Bad Request for url: [https://pge.sharepoint.com/sites/VMDataRequests15/_api/Web/lists/GetByTitle('SI%20Tracker%20-%20Dev')/Fields")](https://pge.sharepoint.com/sites/VMDataRequests15/_api/Web/lists/GetByTitle('SI%20Tracker%20-%20Dev')/Fields%22))
The text was updated successfully, but these errors were encountered:
I have been successful adding fields to an existing list in Sharepoint with FieldCreationInformation with just the column name and column type but when I try using the choices parameter I am getting an HTTP Error.
I am using Office365-REST-Python-Client 2.5.3
Here is my code:
``
from office365.sharepoint.fields.creation_information import FieldCreationInformation
from office365.sharepoint.client_context import ClientContext
from office365.runtime.auth.client_credential import ClientCredential
ctx = ClientContext(site_url).with_credentials(ClientCredential(client_id, client_secret))
choices= ["Choice 1", "Choice 2"]
field_info = FieldCreationInformation("TestChoice", FieldType.Choice, choices=choices)
existing_list = ctx.web.lists.get_by_title("SI Tracker - Dev")
existing_list.fields.add(field_info)
ctx.execute_query()
The text was updated successfully, but these errors were encountered: