# Setting encoding to application/json

**URL:** <https://techcommunity.softwareag.com/t/setting-encoding-to-application-json/101910>\
**Category:** Forum\
**Tags:** mobile\
**Created:** [November 22, 2012, 10:22pm UTC](https://techcommunity.softwareag.com/t/setting-encoding-to-application-json/101910 "2012-11-22T22:22:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jesper\_Loell](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/jesper_loell/32/203_2.png) [@Jesper\_Loell](https://techcommunity.softwareag.com/u/Jesper_Loell)\
**Post date:** [November 22, 2012, 10:22pm UTC](https://techcommunity.softwareag.com/t/setting-encoding-to-application-json/101910/1 "2012-11-22T22:22:00Z")

</div>

Hi all,

I’m doing a mobile app that connects to an IS which has the xWmJSON package content handlers running.

For the content handlers to activate, the post data from the mobile app must be sent using application/json in Content-Type.

How can I do this in wMMD? There are only four encoding formats in the HttpConnectionHandler and application/json is not one of those.

Cheers,

Jesper

* * *

Jesper Loell | Solution Architect | Software AG | +45 2245 7356

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [November 23, 2012, 12:02pm UTC](https://techcommunity.softwareag.com/t/setting-encoding-to-application-json/101910/2 "2012-11-23T12:02:00Z")

</div>

Hi Jesper,

If you take a look inside the HttpConnectionHandler.java class you’ll see those headers from the encoding formats are set using the setPostHeaders() method. If you want to customize that routine, I’d guess the simplest way would be to create a class which extends HttpConnectionHandler and implements that method. Something like this:

public class HttpConnectionHandlerCustom extends HttpConnectionHandler

{

```
        public static final int Encoding_JSON = 4;

        public void setPostHeaders() throws IOException

        {

                    super();

                    if (init_encoding_format == Encoding_JSON)

                    {

                                conn.setRequestProperty (&quot;Content-Type&quot;, &quot;application/json&quot;);

                                conn.setRequestProperty (&quot;Accept&quot;, &quot;*/*&quot;);

                    }

        }

```

}

I’ll also look to see if we can add this to our current list where appropriate.

Cheers,

Matt

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [November 23, 2012, 1:52pm UTC](https://techcommunity.softwareag.com/t/setting-encoding-to-application-json/101910/3 "2012-11-23T13:52:00Z")

</div>

I believe you may also be able to override this by passing in custom "String request\_properties " to the existing openHttpConnection… method.

Regards,

Nick.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 3:02pm UTC](https://techcommunity.softwareag.com/t/setting-encoding-to-application-json/101910/4 "2021-04-02T15:02:39Z")

</div>


