Including custom metadata when uploading a file using the FileClient.upload_file() results in a 400 Bad Request response.
Example:
metadata = {
"custom_name": "data.bin",
"description": "This is a test file.",
}
try:
http_config = JupyterHttpConfiguration()
file_client = FileClient(http_config)
with open("data.bin", "rb") as file:
file_client.upload_file(
file=file,
metadata=metadata,
)
except Exception as e:
print(f"Error uploading file: {e}")
Output:
Error uploading file: Server responded with <400 Bad Request> (https://test-api.lifecyclesolutions.ni.com/nifile/v1/service-groups/Default/upload-files).
name='SkylineWebServices.ErrorParsingRequest' code=-252216 message='The metadata field was specified as a file.' args=[] resource_type=None resource_id=None inner_errors=[]
Using requests directly or testing the endpoint directly from the Swagger page does work correctly when including metadate. based on the server error upload_file seems to include metadata as a file upload instead of a plain form field.
Including custom metadata when uploading a file using the
FileClient.upload_file()results in a400 Bad Requestresponse.Example:
Output:
Using
requestsdirectly or testing the endpoint directly from the Swagger page does work correctly when including metadate. based on the server errorupload_fileseems to include metadata as a file upload instead of a plain form field.