# Http Post with header, body

**URL:** <https://forum.inductiveautomation.com/t/http-post-with-header-body/60895>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [June 17, 2022, 3:52pm UTC](https://forum.inductiveautomation.com/t/http-post-with-header-body/60895 "2022-06-17T15:52:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cbarker](https://avatars.discourse-cdn.com/v4/letter/c/c6cbf5/32.png) [@cbarker](https://forum.inductiveautomation.com/u/cbarker)\
**Post date:** [June 17, 2022, 3:52pm UTC](https://forum.inductiveautomation.com/t/http-post-with-header-body/60895/1 "2022-06-17T15:52:49Z")

</div>

Hello all  
I am trying to interact with Microsoft Azure to send messages to teams. To do this, it needs to send http, both gets and posts  
I have my post command working in postman, but it does not work in ignition. I tried both system.net.httppost, and system.net.httpclient and then using said client to post, but neither work.  
The data has to be sent as x-www-form-urlencoded which is set in the header (or the param for the direct call), but I cannot figure out how to set the body data.

code, with areas commented out due to keys

```auto
accessTokenURL = "https://login.microsoftonline.com/" + tenantID + "/oauth2/v2.0/token"
content_type="application/x-www-form-urlencoded"
	
	#body
	
	body= {
		"grant_type":"client_credentials",
		"client_secret":"<secret string>",
		"client_id":"<id>",
		"scope":"https://graph.microsoft.com/.default"
	}

accessTokenResponse = system.net.httpPost(accessTokenURL, contentType = content_type,postData = body, throwOnError = False)

```

Thank you for your help

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 17, 2022, 4:29pm UTC](https://forum.inductiveautomation.com/t/http-post-with-header-body/60895/2 "2022-06-17T16:29:44Z")

</div>

You definitely want to use `httpClient` over `httpPost`. However, `httpClient` (currently) doesn't have special handling for POST parameters, so you'll have to manually encode, e.g. with urllib:

> [@Problems with Talk2M DMWeb API through system.net.httpClient and system.net.httpPost](https://forum.inductiveautomation.com/t/problems-with-talk2m-dmweb-api-through-system-net-httpclient-and-system-net-httppost/40441/7):
>
> Right! I forgot to encode the data object -\_- This will solve the problem when using the httpClient: import urllib data=urllib.urlencode({"t2mdevid":devId,"t2mtoken":t2mtoken}) Anyway, I can’t get the httpPost to work

---

<div class="post-metadata">

**Author:** ![cbarker](https://avatars.discourse-cdn.com/v4/letter/c/c6cbf5/32.png) [@cbarker](https://forum.inductiveautomation.com/u/cbarker)\
**Post date:** [June 17, 2022, 4:36pm UTC](https://forum.inductiveautomation.com/t/http-post-with-header-body/60895/3 "2022-06-17T16:36:26Z")

</div>

Thank you for this information. If possible, can you link that solution on the system.net.httppost and http clien pages?
