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

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]>

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]>

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?

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/)

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.

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

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.