# No parameters coming through when testing WebDev doPost?

**URL:** <https://forum.inductiveautomation.com/t/no-parameters-coming-through-when-testing-webdev-dopost/62989>\
**Category:** Ignition\
**Tags:** scripting, ignition81\
**Created:** [August 15, 2022, 5:11am UTC](https://forum.inductiveautomation.com/t/no-parameters-coming-through-when-testing-webdev-dopost/62989 "2022-08-15T05:11:12Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [August 15, 2022, 5:11am UTC](https://forum.inductiveautomation.com/t/no-parameters-coming-through-when-testing-webdev-dopost/62989/1 "2022-08-15T05:11:12Z")

</div>

I have set up the following web dev resource for doPost:

```auto
def doPost(request,session):
	logger = system.util.getLogger("ERP_Integration")
	scriptName = 'Web Dev/volCompliance/doPost'
	authProfile = "ERP_Users"
	currDate = shared.util.getGatewayDateTime()
	currDateStr = system.date.format(currDate,"yyyy-MM-dd HH:mm:ss")
	
	logger.info(scriptName + ' - inbound httpPOST request detected')
	logger.debug(scriptName + ' - session data: %s' % (str(session)))
	logger.debug(scriptName + ' - parameters: %s' % (str(request['params'])))
	logger.debug(scriptName + ' - headers: %s' % (str(request['headers'])))
	####logger.debug(scriptName + ' - data: %s' % (str(request['data'])))
	
	
	#------------------ Get request parameters -----------------#
	# if application/json data is used inbound, access like this:
	# param = request['params'].get("paramName")
	groupID = request['params'].get("pfmGroupID")
	gradeID = request['params'].get("pfmGradeID")
# end def

```

I am building a test function as follows:

```auto
def test_incomingPOST():
	scriptName = "shared.api.test_incomingPO"
	logger.info(scriptName + " - script started")	

	url = "http://myhostname:8088/main/system/webdev/ERP_Test/volCompliance"
	params = {"pfmStartDate":'2022-08-20 00:30:00',"pfmEndDate":'2022-08-27 10:30:00',"pfmGroupID":"GROUP1","pfmGradeID":"-ABC","pfmThickID":"50","pfmWidthID":"200","pfmLengthID":"4050","pfmVolume":"0.457","pfmLocationID":"WDM"}
	jsonMsg = system.util.jsonEncode(params)
	
	response = system.net.httpClient().post(url=url,params=params)
	###response = system.net.httpPost(url,contentType="application/json",params=jsonMsg, throwOnError=True)
	####logger.info(scriptName + " - response status: %s" % response.statusCode)
	
	return system.util.jsonDecode(response.json)
	###return system.util.jsonDecode(response)
# end def

```

When calling this test function, the output of my logger is showing there are **no parameters**.  
I’m going a bit nuts here, can someone point out where i’m going wrong sending parameters to the endpoint?  
I’ve tried both the `system.net.httpClient` and `system.net.httpPost` in-built functions, both providing same issue.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/c/9c21b437cd518131360ff4b9980e80c93ad66318.png)

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 15, 2022, 1:18pm UTC](https://forum.inductiveautomation.com/t/no-parameters-coming-through-when-testing-webdev-dopost/62989/2 "2022-08-15T13:18:00Z")

</div>

You should be looking at the `data` or `postData`, not `params`. `params` are URL parameters, not a request body.

Edit: errr n/m, you’re posting with params too… Hmm

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 15, 2022, 1:31pm UTC](https://forum.inductiveautomation.com/t/no-parameters-coming-through-when-testing-webdev-dopost/62989/3 "2022-08-15T13:31:57Z")

</div>

What’s under here?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/8/8813757ef20faf9380d7a64184efe07c9471a49a.png)

---

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [August 15, 2022, 8:44pm UTC](https://forum.inductiveautomation.com/t/no-parameters-coming-through-when-testing-webdev-dopost/62989/4 "2022-08-15T20:44:30Z")

</div>

> [@Kevin.Herron](#):
>
> What's under here?
> 
> ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/8/8813757ef20faf9380d7a64184efe07c9471a49a.png)

That is just an error telling me there is nothing when i try to access parameters via:

```auto
groupID = request['params'].get("pfmGroupID")

```

and then try and use groupID somewhere. It complains about it being None.

---

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [August 15, 2022, 10:22pm UTC](https://forum.inductiveautomation.com/t/no-parameters-coming-through-when-testing-webdev-dopost/62989/5 "2022-08-15T22:22:18Z")

</div>

Ok so tried to dumb it down a bit, and got some partial success. but something still seems fishy…

Simplified the function call to this:

```auto
response = system.net.httpPost(url, {"pfmGroupID":"13456"})
print system.util.jsonDecode(response)

```

When there were other issues inside the WebDev endpoint, i got the following exception, which finally implied i was sending the parameter in the URL:

`IOError: Server returned HTTP response code: 501 for URL: http://172.20.7.94:8088/system/webdev/ERP_Test/volCompliance?pfmGroupID=13456`

What has thrown me for a loop is the logger showing the value and type of the parameter passed through:

```auto
ERP_Integration	16Aug2022 10:17:24	Web Dev/volCompliance/doPost - inbound httpPOST request detected
ERP_Integration	16Aug2022 10:17:24	Web Dev/volCompliance/doPost - data: array('b')
ERP_Integration	16Aug2022 10:17:24	Web Dev/volCompliance/doPost - headers: {'Cookie': u'JSESSIONID=node02o79ir60n77cqp8spcouz1ct64.node0', 'Accept': u'text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2', 'User-Agent': u'Java/11.0.15', 'Connection': u'keep-alive', 'Host': u'172.20.7.94:8088', 'Content-Length': u'16', 'Content-Type': u'application/x-www-form-urlencoded'}
ERP_Integration	16Aug2022 10:17:24	Web Dev/volCompliance/doPost - parameters: {'pfmGroupID': (u'13456', u'13456')}
ERP_Integration	16Aug2022 10:17:24	Web Dev/volCompliance/doPost - session data: {u'user': {badge=null, schedule=Always, firstname=SAP01, notes=Test user for SAP inbound connections, language=en, user.pin=, username=SAP01, lastname=null}}
ERP_Integration	16Aug2022 10:17:24	

```

Why would the pfmGroupID parameter be a tuple now…?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 15, 2022, 10:30pm UTC](https://forum.inductiveautomation.com/t/no-parameters-coming-through-when-testing-webdev-dopost/62989/6 "2022-08-15T22:30:39Z")

</div>

Does the same thing happen if you use system.net.httpClient instead?

---

<div class="post-metadata">

**Author:** ![kcollins](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kcollins/32/19646_2.png) [@kcollins](https://forum.inductiveautomation.com/u/kcollins)\
**Post date:** [August 15, 2022, 10:34pm UTC](https://forum.inductiveautomation.com/t/no-parameters-coming-through-when-testing-webdev-dopost/62989/7 "2022-08-15T22:34:53Z")

</div>

I did observe a small error in our docs page for [system.net.httpClient()](https://docs.inductiveautomation.com/display/DOC81/system.net.httpClient) regarding `redirect_policy`. It defaults to “NEVER” (not “NORMAL”) when unspecified. That is now corrected.

I think you’re probably going to run into problems trying to send all of that through as URL parameters. It seems more apropos to do a POST with a request body. That said, I was able to mock this up successfully:

 ![2022-08-15 at 5.05 PM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/0/101dad8251fe1505f74935f1c12e37097209854d.png)

If your `params` entries have spaces in them (or other special characters), you’ll probably encounter errors such as:

```auto
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Illegal character in query at index 106: http://...

```

---

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [August 15, 2022, 10:36pm UTC](https://forum.inductiveautomation.com/t/no-parameters-coming-through-when-testing-webdev-dopost/62989/8 "2022-08-15T22:36:03Z")

</div>

> [@Kevin.Herron](#):
>
> Does the same thing happen if you use system.net.httpClient instead?

Let me check...

And another discovery... probably obvious to someone who deals with HTTP requests a lot, but the reason my parameters weren't getting sent to the endpoint correctly was due to invalid formatting of the **date variables**. It seems obvious in hindsight, but you cannot send a parameter string that looks like this:

```auto
IOError: Server returned HTTP response code: 400 for URL: http://172.20.7.94:8088/system/webdev/ERP_Test/volCompliance?pfmWidthID=200&pfmLengthID=4050&pfmStartDate=2022-08-20 00:30:00&pfmVolume=0.457&pfmLocationID=WDM&pfmGradeID=-ABC&pfmEndDate=2022-08-27 10:30:00&pfmGroupID=GROUP1&pfmThickID=50

```

Happy days if you format the date strings in a more URL friendly way such as:

```auto
?pfmWidthID=200&pfmLengthID=4050&pfmStartDate=2022-08-20&pfmVolume=0.457

```

Or i'm sure there are industry standards such as:

```auto
date=2012-12-31T22:00:00.000Z .

```

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 15, 2022, 10:36pm UTC](https://forum.inductiveautomation.com/t/no-parameters-coming-through-when-testing-webdev-dopost/62989/9 "2022-08-15T22:36:04Z")

</div>

> [@kcollins](#):
>
> I think you’re probably going to run into problems trying to send all of that through as URL parameters. It seems more apropos to do a POST with a request body.

Agreed.

And I ask about system.net.httpClient instead because system.net.httpPost seems to always send the provided parameters as body, not URL parameters.

---

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [August 15, 2022, 10:38pm UTC](https://forum.inductiveautomation.com/t/no-parameters-coming-through-when-testing-webdev-dopost/62989/10 "2022-08-15T22:38:05Z")

</div>

Yes that was the problem… funny characters in the URL.

I would like to do a POST with request body but i seem to have forgotten how to do that. I think i did it in Javascript in some other project, but struggling a bit atm to recall it.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 15, 2022, 10:39pm UTC](https://forum.inductiveautomation.com/t/no-parameters-coming-through-when-testing-webdev-dopost/62989/11 "2022-08-15T22:39:26Z")

</div>

Just supply a `data` parameter instead of `params` when using `system.net.httpClient`

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 15, 2022, 10:41pm UTC](https://forum.inductiveautomation.com/t/no-parameters-coming-through-when-testing-webdev-dopost/62989/12 "2022-08-15T22:41:00Z")

</div>

Also, if you do want to use URL params, system.net.httpClient will encode them for you, as long as the params object you provide is a dictionary and not pre-encoded JSON like you were doing. If you encode it yourself you are responsible for URL escaping the contents.

---

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [August 15, 2022, 10:58pm UTC](https://forum.inductiveautomation.com/t/no-parameters-coming-through-when-testing-webdev-dopost/62989/13 "2022-08-15T22:58:42Z")

</div>

Ok, and presumably if using `system.net.httpPost`, using the `postData` and sending as a json encoded string does the equivalent?

Struggling to get `system.net.httpClient` working at the moment but i think i have enough to go by at the moment.

**EDIT:** Managed to get the data coming in properly using httpPost, and postData. Values no longer coming through as tuples like they did when sent as URL parameters…  
I vaguely remember this being an issue on my other project too actually…

Thanks for the help guys.
