zfcampus/zf-content-negotiation

Fatal errorUncaught exception ZF\ContentNegotiation\Exception\InvalidMultipartContentException

egyptianbman opened this issue · 1 comments

Hello,

I'm following the guide at https://apigility.org/documentation/recipes/upload-files-to-api and upon saving my configs after setting file upload to yes and adding multipart/form-data to the Content-Type whitelist, sending a request in postman with multipart/form-data yields:

<b>Fatal error</b>:  Uncaught exception 'ZF\ContentNegotiation\Exception\InvalidMultipartContentException' in /.../vendor/zfcampus/zf-content-negotiation/src/MultipartContentParser.php:35
Stack trace:
#0 /.../vendor/zfcampus/zf-content-negotiation/src/ContentTypeListener.php(80): ZF\ContentNegotiation\MultipartContentParser-&gt;__construct(Object(Zend\Http\Header\ContentType), Object(ZF\ContentNegotiation\Request))
#1 [internal function]: ZF\ContentNegotiation\ContentTypeListener-&gt;__invoke(Object(Zend\Mvc\MvcEvent))
#2 /.../vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(468): call_user_func(Object(ZF\ContentNegotiation\ContentTypeListener), Object(Zend\Mvc\MvcEvent))
#3 /.../vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(207): Zend\EventManager\EventManager-&gt;triggerListeners('route', Object(Zend\Mvc\MvcEven in 
<b>/.../vendor/zfcampus/zf-content-negotiation/src/MultipartContentParser.php</b> on line 
<b>35</b>
<br />

After much much digging I found that you don't need to send a Content-Type header in postman. Doing so hinders postman from adding the boundary dynamically.

Source: postmanlabs/postman-app-support#191 (comment)