# How to convert content-type: application/x-www-form-urlencoded to json

**URL:** <https://forum.serverless.com/t/how-to-convert-content-type-application-x-www-form-urlencoded-to-json/15922>\
**Category:** Serverless Framework\
**Tags:** api-gateway\
**Created:** [September 13, 2021, 8:53pm UTC](https://forum.serverless.com/t/how-to-convert-content-type-application-x-www-form-urlencoded-to-json/15922 "2021-09-13T20:53:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lormayna](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/lormayna/32/6187_2.png) [@lormayna](https://forum.serverless.com/u/lormayna)\
**Post date:** [September 13, 2021, 8:53pm UTC](https://forum.serverless.com/t/how-to-convert-content-type-application-x-www-form-urlencoded-to-json/15922/1 "2021-09-13T20:53:36Z")

</div>

Hello everyone,  
I am prettty new with AWS cloud and I am struggling on a silly problem.  
I have a simple HTML form that send data as “content-type: application/x-www-form-urlencoded” to API GW. When I tried to read the data from Lambda event, I got this in request body: email=test%[40test.com](http://40test.com) and I am not able to convert in JSON.

Is there a way to convert it to JSON through API GW?  
I tried using mapping templates, but I am bit lost.  
This is the important part of my serverless.yml:

> Blockquote  
> functions:  
> subscribe:  
> handler: bin/register  
> memorySize: 128  
> events:  
> - httpApi:  
> path: /register  
> method: post  
> integration: lambda  
> request:  
> passThrough: NEVER  
> template:  
> application/x-www-form-urlencoded: $input.json(‘$’)

Where I am doing wrong?

---

<div class="post-metadata">

**Author:** ![buggy](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/buggy/32/177_2.png) [@buggy](https://forum.serverless.com/u/buggy)\
**Post date:** [September 14, 2021, 12:58pm UTC](https://forum.serverless.com/t/how-to-convert-content-type-application-x-www-form-urlencoded-to-json/15922/2 "2021-09-14T12:58:17Z")

</div>

> [@lormayna](#):
>
> Is there a way to convert it to JSON through API GW?

No. If you’re using `application/x-www-form-urlencoded` encoded content then it’s URL encoded string. You need to URL decode the body to access the data. If you’re using nodejs then you might be able to use `URLSearchParams`.

---

<div class="post-metadata">

**Author:** ![lormayna](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/lormayna/32/6187_2.png) [@lormayna](https://forum.serverless.com/u/lormayna)\
**Post date:** [September 14, 2021, 3:04pm UTC](https://forum.serverless.com/t/how-to-convert-content-type-application-x-www-form-urlencoded-to-json/15922/3 "2021-09-14T15:04:24Z")

</div>

I am using Go.  
Thank you.
