# REST API system.net.httpClient() - Post Errors 415, 400

**URL:** <https://forum.inductiveautomation.com/t/rest-api-system-net-httpclient-post-errors-415-400/76744>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [July 22, 2023, 5:32pm UTC](https://forum.inductiveautomation.com/t/rest-api-system-net-httpclient-post-errors-415-400/76744 "2023-07-22T17:32:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![r123](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@r123](https://forum.inductiveautomation.com/u/r123)\
**Post date:** [July 22, 2023, 5:32pm UTC](https://forum.inductiveautomation.com/t/rest-api-system-net-httpclient-post-errors-415-400/76744/1 "2023-07-22T17:32:34Z")

</div>

I was able to get data from an Azure database and put it into a Perspective Table in Ignition but I'm having trouble formatting the Post into the database. When I successfully do it through Postman, there's quite a few headers that it adds and I'm not sure which ones are required by system.net.httpClient() if any.

With the code below, I get a 415 – Unsupported Media Type error.

`'https://TEST-api.azurewebsites.net/datapoints?point=Temp&unit=1X&system=System+X&sector=175X&value=87.6&timestamp=2023-07-21T01%3A00%3A00.053Z' [415]>`

```auto
TagList = {
"system": "System X",
"sector": "175X",
"unit": "1X",
"point": "Temp",
"value": 87.6,
"timestamp": "2023-07-21T00:00:00.053Z"
}

client = system.net.httpClient()

url = self.parent.parent.getChild("FlexContainer_datapoints_URL").getChild("TextField").props.text

Response = client.post(url, TagList, username="admin", password="!%^$!")

```

I thought the TagList object would be converted to JSON but if I try to add the Content-Type Header I do then get the 400 – Bad Request error.

`'https://TEST-api.azurewebsites.net/datapoints?point=Temp&unit=1X&system=System+X&sector=175X&value=87.6&timestamp=2023-07-21T01%3A00%3A00.053Z' [400]>`

```auto
SentHeaders = {'Content-Type': 'application/json'}

Response = client.post(url, TagList, headers = SentHeaders, username="adc_admin", password="!%^$!")

```

The working Post in Postman shows a lot more request headers and so on but I'm not sure what else the Ignition post function requires to work. Token, Cookie?

```auto
POST https://TEST-api.azurewebsites.net/datapoints
200
747 ms
Network
Request Headers
Content-Type: application/json
Authorization: Basic wwQ0gzMExAJCE=
User-Agent: PostmanRuntime/7.32.3
Accept: */*
Postman-Token: 4147c0625
Host: [TEST-api.azurewebsites.net](http://TEST-api.azurewebsites.net/)
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 153
Cookie: ARRAffinity=625456a57; ARRAffinitySameSite=625456a5791

Request Body
{
"system": "System X",
"sector": "175X",
"unit": "1X",
"point": "Temp",
"value": 87.6,
"timestamp": "2023-07-21T00:00:00.053Z"
}

Response Headers
Content-Length: 0
Date: Sat, 22 Jul 2023 15:20:33 GMT
Server: Microsoft-IIS/10.0
Request-Context: appId=cid-
X-Powered-By: [ASP.NET](http://asp.net/)

```

---

<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:** [July 22, 2023, 6:03pm UTC](https://forum.inductiveautomation.com/t/rest-api-system-net-httpclient-post-errors-415-400/76744/2 "2023-07-22T18:03:35Z")

</div>

> [@r123](#):
>
> The working Post in Postman shows a lot more request headers and so on but I'm not sure what else the Ignition post function requires to work.

The Ignition side doesn't require anything. It's a question of what the server requires...

Try using a named parameter when you pass `TagList`. I'm worried you're passing it as `params` rather than `data` right now. e.g.

```auto
Response = client.post(url, data=TagList, username="admin", password="!%^$!")

```

---

<div class="post-metadata">

**Author:** ![r123](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@r123](https://forum.inductiveautomation.com/u/r123)\
**Post date:** [July 22, 2023, 8:01pm UTC](https://forum.inductiveautomation.com/t/rest-api-system-net-httpclient-post-errors-415-400/76744/3 "2023-07-22T20:01:29Z")

</div>

Yeah but it's the Ignition side that's passing stuff along and looking at all those headers, I have no clue about what is automatically sent or how much that differs from my working Postman example and what may need to be added.

I had used the "data=" at one point following an example but it must have had other issues at that time. But that did the trick. Thanks.
