# Transitioning from system.net.httpPost() to system.net.httpClient()

**URL:** <https://forum.inductiveautomation.com/t/transitioning-from-system-net-httppost-to-system-net-httpclient/59558>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [May 13, 2022, 8:06pm UTC](https://forum.inductiveautomation.com/t/transitioning-from-system-net-httppost-to-system-net-httpclient/59558 "2022-05-13T20:06:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevin.deyoung](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.deyoung/32/9558_2.png) [@kevin.deyoung](https://forum.inductiveautomation.com/u/kevin.deyoung)\
**Post date:** [May 13, 2022, 8:06pm UTC](https://forum.inductiveautomation.com/t/transitioning-from-system-net-httppost-to-system-net-httpclient/59558/1 "2022-05-13T20:06:30Z")

</div>

Due to httpPost() being deprecated in the future I’m attempting to transition a working SOAP interface to httpClient() as suggested in a number of discussions. I attempted to view differences in the frame on the wire and found that my post isn’t making it to the wire due to http error 415 “Unsupported Media Type”. All my headers seem to be the same and body is absolutely the same. Not quite sure what attributes would cause the 415 now that I’m using httpClient(). There weren’t any SOAP based examples that I could find using the system.net.httpClient() function.

My data element is an XML string. If I eliminate the data element the request goes out on the wire but obviously fails with no payload. So I’m assuming there is something wrong with my method of identifying the content-type.

* * *

```auto

dataservice = 'http://cwa112300q:50211/TTPMESWS'

soapenv = """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:laetus.com:ws:tts:mes">
   <soapenv:Header/>
   <soapenv:Body>
      <urn:SetMaterial>
         <Identifier>KRD302</Identifier>
         <Description>KRD Material 302</Description>
         <TargetLevel>Carton</TargetLevel>
         <Item>
            <Identifier>302</Identifier>
            <Description>Product 302</Description>
            <Level>Carton</Level>
            <Action>C</Action>
         </Item>
      </urn:SetMaterial>
   </soapenv:Body>
</soapenv:Envelope>"""

myheaders = {
        'SOAPAction': 'SetMaterial',
        'Context-type' : 'text/xml;charset=UTF-8'
}

try:
	client = system.net.httpClient()
	response = client.post(url=dataservice,headers=myheaders,data=soapenv,username=user,password=pwd)

```

---

<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:** [May 13, 2022, 8:48pm UTC](https://forum.inductiveautomation.com/t/transitioning-from-system-net-httppost-to-system-net-httpclient/59558/2 "2022-05-13T20:48:40Z")

</div>

> [@kevin.deyoung](#):
>
> `Context-type`

Should probably be **Content** -type, no?

---

<div class="post-metadata">

**Author:** ![kevin.deyoung](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.deyoung/32/9558_2.png) [@kevin.deyoung](https://forum.inductiveautomation.com/u/kevin.deyoung)\
**Post date:** [May 13, 2022, 9:56pm UTC](https://forum.inductiveautomation.com/t/transitioning-from-system-net-httppost-to-system-net-httpclient/59558/3 "2022-05-13T21:56:05Z")

</div>

I wish those trees would get out of the way so I could see the forest. Sigh…  
Good catch. Don’t know how I managed that.  
Thank you!
