DB connection Count need to post on api_endpoint

DB connection Count neet to post on api_endpoint

basePath = "[System]Gateway/Database"
results = system.tag.browse(basePath)
print len(results)

headers = {"Content-Type": "text/plain"}

#charset=utf-8"
#api_endpoint = "[http://my-json-server.typicode.com/typicode/demo/posts"](http://my-json-server.typicode.com/typicode/demo/posts%22)
api_endpoint = "[http://localhost:14499/metrics/ingest"](http://localhost:14499/metrics/ingest%22)

# 

# 
data = {"ignition.dbconnection,db=1": len(results) }

# 
response = system.net.httpPost(api_endpoint,data,headers)

print response

i get this error "IOError: Connection refused: getsockopt" can anyone help me

Please see Wiki - how to post code on this forum. There's an edit icon below your post so you can fix it.

This looks like markdown. Did you copy this from somewhere and just paste it?

It may help if you just use
api_endpoint = "http://localhost:14499/metrics/ingest"

2 Likes

@Benjamin_Furlani changes done still getting the same error

error:

I would have to say the endpoint is either incorrect in some way (port, or it is not hosted on localhost), or the port is blocked.

I would suggest you can access this API and send data to it via Postman to verify.