No Result found for SubscriberList with id 0

This is found working with post man., with following python script it keeps showing the error.

--------------SCRIPT-------------------
import requests

API_URL_LISTS = “https://thirdrepublic.api-us1.com/api/3/contactLists?api_key=<<<>>>>”

response = requests.request(“PUT”, API_URL_LISTS, data=‘{ “contactList”: { “list”: 1, “contact”: 439, “status”: 1 } }’)

print(response.text)

-------------------RESULTS---------------------

[root@master-node live]# python test.py
{“message”:“No Result found for SubscriberList with id 0”}


AC Support claims that it is working as it is working with postman. I am not able to figure out what is the problem with above script!

I am using same script to implement other APIs and found working.

I think the issue might be your data is not getting parsed and sent as JSON. Here’s a working example I tested. Update the values to match your host, API key, list, and contact IDs.

import json
import requests

hostName = 'yourHostName'
apiKey = 'yourApiKey'
list_id = '123'
contact_id = '456'
status = '1'

url = 'https://{0}.api-us1.com/api/3/contactLists'.format(hostName)
headers = {'user-agent': 'ac-python-test/0.0.1',
           'Api-Token': apiKey}

body = '{"contactList": { "list": ' + list_id + \
    ', "contact": ' + contact_id + ', "status": ' + status + ' }}'
data = json.loads(body)

print('sending to API: {0}'.format(data))
response = requests.post(url, headers=headers, json=data)

print(response.json())

I hope this helps!