Cannot upload a file through the API with the synchronous parameter

Code looks correct. What does your.discourse/logs show when you get the 500?