PHPackages                             wubinworks/module-webapi - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. wubinworks/module-webapi

ActiveMagento2-module[API Development](/categories/api)

wubinworks/module-webapi
========================

\[1\] Add support for `application/wubinworks-x-www-form-urlencoded`. \[2\] Conditionally modifies JSON output behavior. See https://github.com/wubinworks/magento2-module-webapi

1.0.0(2y ago)0825OSL-3.0PHPPHP &gt;=7.3

Since Sep 22Pushed 2y ago1 watchersCompare

[ Source](https://github.com/wubinworks/magento2-module-webapi)[ Packagist](https://packagist.org/packages/wubinworks/module-webapi)[ RSS](/packages/wubinworks-module-webapi/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Features and Usage
==================

[](#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,

```
return [
    'code' => 0,
    'message' => 'Success',
    'data' => [
        'customer_id' => 1
    ]
];

```

Magento encloses the returned data in an array parentheses and property names got stripped out.
Output:

```
[
    0,
    "Success",
    {
        "customer_id": 1
    }
]

```

This may be not what you want.
If the service class returns

```
return [
    'dummy' => [
        'code' => 0,
        'message' => 'Success',
        'data' => [
            'customer_id' => 1
        ]
    ]
];

```

the output becomes

```
[
    {
        "code": 0,
        "message": "Success",
        "data": {
            "customer_id": 1
        }
    }
]

```

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.,

```
return [
    'code' => 0,
    'message' => 'Success',
    'data' => [
        'customer_id' => 1
    ],
    'type' => 'simple_array' // Add this key-value pair
];

```

Then output will be

```
{
    "code": 0,
    "message": "Success",
    "data": {
        "customer_id": 1
    }
}

```

**Note: the JSON output will not have `"type": "simple_array"`, it got removed!**

Requirements
============

[](#requirements)

**Only tested under Magento 2.4**

Installation
============

[](#installation)

**`composer require wubinworks/module-webapi`**

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

969d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7de965a6287fb784969afeb4b173521d3cb59c6b873b7248263abb9fc098eddd?d=identicon)[wubinworks](/maintainers/wubinworks)

---

Top Contributors

[![wubinworks](https://avatars.githubusercontent.com/u/127310257?v=4)](https://github.com/wubinworks "wubinworks (1 commits)")

---

Tags

apiapi-restjapanesejsonmagento2magento2-modulewebapix-www-form-urlencoded

### Embed Badge

![Health badge](/badges/wubinworks-module-webapi/health.svg)

```
[![Health](https://phpackages.com/badges/wubinworks-module-webapi/health.svg)](https://phpackages.com/packages/wubinworks-module-webapi)
```

###  Alternatives

[smile/elasticsuite

Magento 2 merchandising and search engine built on ElasticSearch

8044.5M33](/packages/smile-elasticsuite)[mollie/magento2

Mollie Payment Module for Magento 2

1121.6M10](/packages/mollie-magento2)[graycore/magento2-cors

A Magento 2 module that enables CORS on the GraphQL and REST Apis

99516.1k](/packages/graycore-magento2-cors)[elgentos/module-prismicio

Magento 2 - Prismic.io integration

39112.0k3](/packages/elgentos-module-prismicio)[zepgram/module-rest

Technical module to industrialize API REST call with dependency injection pattern using Guzzle library

1326.2k](/packages/zepgram-module-rest)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
