# HTTP POST with JSON

**URL:** <https://forum.servoy.com/t/http-post-with-json/17177>\
**Category:** Classic Servoy\
**Created:** [April 14, 2013, 9:59pm UTC](https://forum.servoy.com/t/http-post-with-json/17177 "2013-04-14T21:59:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![antonio](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@antonio](https://forum.servoy.com/u/antonio)\
**Post date:** [April 14, 2013, 9:59pm UTC](https://forum.servoy.com/t/http-post-with-json/17177/1 "2013-04-14T21:59:49Z")

</div>

Hi, trying to do a REST call with

```auto
	var vJSON = plugins.serialize.fromJSON("{'ID':'XXX23456','Details':[{'ACMyFee':332.65,'ACmyRate':45.0,'ACUUID':'FDB895C9-5B03-4AEE-BEAA-E5A235A00555','ACNumber':2345}]}")
	var vURL = "http://localhost:8080/servoy-service/rest_ws/mod_rest_ws/ws_api"
	plugins.http.setTimeout(10)
	var poster = plugins.http.getPoster(vURL)  
//	var didAddParam = poster.addParameter('claim',vJSON);
//	var didAddFile = poster.addFile('myFileParamName','manual.doc','c:/temp/manual_01a.doc');
	poster.addParameter("Content-Type","application/json")
	poster.setCharset('UTF-8')
	poster.addParameter(null,vJSON)
	var httpCode = poster.doPost(); //httpCode 200 is ok
	var pageData = poster.getPageData()

```

I keep getting Error 415 - The server refused this request because the request entity is in a format not supported by the requested resource for the requested method

I’ve tried variations on the format of the JSON, the parameters etc with no luck

---

<div class="post-metadata">

**Author:** ![mboegem](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/mboegem/32/4399_2.png) [@mboegem](https://forum.servoy.com/u/mboegem)\
**Post date:** [April 15, 2013, 8:10am UTC](https://forum.servoy.com/t/http-post-with-json/17177/2 "2013-04-15T08:10:27Z")

</div>

Hi Tony,

I’m not so familiar with the serialize plugin, I always use the one from the velocity plugin ([servoyforge.net](http://servoyforge.net))  
Anyway, looking at the tooltips of this plugin, I think you need to go the other way around, ‘plugins.serialize.toJSON’.

One tip: just try to see what the vJSON variable contains.  
If you are not able to read it, the webservice certainly won’t be able to…

---

<div class="post-metadata">

**Author:** ![rgansevles](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@rgansevles](https://forum.servoy.com/u/rgansevles)\
**Post date:** [April 15, 2013, 9:40am UTC](https://forum.servoy.com/t/http-post-with-json/17177/3 "2013-04-15T09:40:51Z")

</div>

Tony,

The poster.addParameter(null,vJSON) call should get a string, not the parsed object.

Rob

---

<div class="post-metadata">

**Author:** ![antonio](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@antonio](https://forum.servoy.com/u/antonio)\
**Post date:** [April 17, 2013, 8:58am UTC](https://forum.servoy.com/t/http-post-with-json/17177/4 "2013-04-17T08:58:59Z")

</div>

Thanks for the assistance, this worked.

```auto
 var vJSON = plugins.serialize.toJSON("{'ID':'XXX23456','Details':[{'ACMyFee':332.65,'ACmyRate':45.0,'ACUUID':'FDB895C9-5B03-4AEE-BEAA-E5A235A00555','ACNumber':2345}]}")
   var vURL = "http://localhost:8080/servoy-service/rest_ws/mod_rest_ws/ws_api"
   plugins.http.setTimeout(10)
   var poster = plugins.http.getPoster(vURL)  
   poster.addHeader('Content-type','text/json; charset=UTF-8')
 // poster.addParameter("Content-Type","application/json")
 // poster.setCharset('UTF-8')
   poster.addParameter(null,vJSON)
   var httpCode = poster.doPost(); //httpCode 200 is ok
   var pageData = poster.getPageData()

```

In fact it also works with vJSON = “{‘ID’:‘XXX23456’,‘Details’:[{‘ACMyFee’:332.65,‘ACmyRate’:45.0,‘ACUUID’:‘FDB895C9-5B03-4AEE-BEAA-E5A235A00555’,‘ACNumber’:2345}]}”
