# system.net.httpPost() throwing error while Postman is not

**URL:** <https://forum.inductiveautomation.com/t/system-net-httppost-throwing-error-while-postman-is-not/44815>\
**Category:** Ignition\
**Tags:** ignition80, perspective\
**Created:** [March 23, 2021, 7:08pm UTC](https://forum.inductiveautomation.com/t/system-net-httppost-throwing-error-while-postman-is-not/44815 "2021-03-23T19:08:38Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [March 23, 2021, 7:28pm UTC](https://forum.inductiveautomation.com/t/system-net-httppost-throwing-error-while-postman-is-not/44815/3 "2021-03-23T19:28:14Z")

</div>

Hi Kevin,

Thanks for the quick response… That ended up being the issue.

Quick fix:

1. Add import statement `from urllib import urlencode`.
2. Call function `urlencode()` on body parameter.

Full function:

```auto
def getAccessToken():
	from urllib import urlencode
	headers = {"Content-Type": "application/x-www-form-urlencoded","Accept": "*/*","Accept-Encoding": "gzip, deflate, br","Connection": "keep-alive"}
	
	body = {"grant_type": "refresh_token","refresh_token": getRefreshToken()}
	
	contentType = "application/x-www-form-urlencoded"
	
	url = getWebServicesRootUrl() + '/services/rest/auth/oauth2/v1/token'

	res = system.net.httpPost(url, 
				contentType = contentType, 
				postData = urlencode(body), 
				username = getClientId(), 
				password = getClientSecret(), 
				headerValues = headers, 
				throwOnError = False
			)
	return res

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/system-net-httppost-throwing-error-while-postman-is-not/44815)._
