[azure-core][bug] wrong content-type in headers of multipart request when there is no file to send #39163
Description
For typespec definition https://github.com/allenjzhang/typespec-e2e-demo/blob/75f5f9ad85acb4e46095058bd1033ba9fe9be0a3/todoApp/spec/main.tsp#L84, the property for file part is optional which means the payload for multipart may not contain file and azure-core shall still send it as multipart payload. However, current azure-core use files
to judge whether the payload is for multipart which is not accurate. If files are empty, the content-type of default_headers
is set to application/x-www-form-urlencoded which is wrong.
azure-sdk-for-python/sdk/core/azure-core/azure/core/rest/_rest_py3.py
Lines 114 to 119 in cb0221a
azure-sdk-for-python/sdk/core/azure-core/azure/core/rest/_rest_py3.py
Lines 155 to 158 in cb0221a
Steps to repro:
- clone
https://github.com/allenjzhang/typespec-e2e-demo.git
- step into the cloned repo and run
npm install
- annotate this line then follow https://github.com/allenjzhang/typespec-e2e-demo/blob/main/todoApp/samples/python/README.md to run the sample and you can get error: