Download the PHP package wubinworks/module-webapi without Composer
On this page you can find all versions of the php package wubinworks/module-webapi. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wubinworks/module-webapi
More information about wubinworks/module-webapi
Files in wubinworks/module-webapi
Package module-webapi
Short Description [1] Add support for `application/wubinworks-x-www-form-urlencoded`. [2] Conditionally modifies JSON output behavior. See https://github.com/wubinworks/magento2-module-webapi
License OSL-3.0
Informations about the package module-webapi
Features and Usage
(Only works for REST endpoints.)
This module is designed as a dependency for developing other modules.
1. Support for Content-Type: application/x-www-form-urlencoded
\
Magento WEBAPI_REST recognizes application/json
, application/xml
, application/xhtml+xml
, text/xml
Content-Type out of the box, any others will result in an error message like
"message": "Server cannot understand Content-Type HTTP header media type application/x-www-form-urlencoded"
However, application/x-www-form-urlencoded
is commonly used in forms and many third part software could only POST this content type.
How to use?\
Just make the request normally using Content-Type: application/x-www-form-urlencoded
and add an additional custom header Use-Deprecated-Content-Type: 1
.\
Note: You MUST include the Use-Deprecated-Content-Type: 1
header in your request, otherwise it does not work!
2. Conditionally modifies JSON output behavior\ When developing a service class(usually a file called someActionManagement.php in Model folder), if it returns an array like below,
Magento encloses the returned data in an array parentheses and property names got stripped out.\ Output:
This may be not what you want.\ If the service class returns
the output becomes
Note the outermost []
, many third party software expects the output to be an object, though.
How to use?\
Add 'type' => 'simple_array'
in the output array, i.e.,
Then output will be
Note: the JSON output will not have "type": "simple_array"
, it got removed!
Requirements
Only tested under Magento 2.4
Installation
composer require wubinworks/module-webapi