Why do you need to set content-length manually? If you refer to official docs you can see that this header is not explicitly specified. Also when appending to form the buffer should be wrapped in File object. Check same link for reference.