CRUD: Create problem in frappe api - [Errno 111] Connection refused

I’m having issue with CRUD operation.
Its giving error while I’m creating:

raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host=‘xx.xxx.xx.xxx’, port=xxx): Max retries exceeded with url: /api/resource/City (Caused by NewConnectionError(’<urllib3.connection.VerifiedHTTPSConnection object at 0x7f5b11cd2ed0>: Failed to establish a new connection: [Errno 111] Connection refused’,))

Also I want to confirm is this the correct way to pass csrf token ?

I’m using python and doing it as:

payload = {
‘usr’:‘administrator’,
‘pwd’:‘admin’,
‘X-Frappe-CSRF-Token’:‘frappe.csrf_token’
}

and then passing this parameter in my url

Figured the connection refused issue. I was by mistaking requesting https://xx.xxx.xx.xxx

Still want to confirm the csrf token part that if I’m wrong, give some references to do so.

Maybe search on ‘X-Frappe-CSRF-Token’ to find what you seek like this:

Please follow up to show the way here with your learning.

After having a look what I came to an end is that I need to pass csrf token in a header and then pass it to POST requests.
This is what I did :

 headers = {
‘X-Frappe-CSRF-Token’: ‘frappe.local.session.data.csrf_token’
}

, and then passed that in POST request.
Is this the correct way to do so ??

Correct me If I am wrong