0

I've been trying to get the insightly api to work with python requests however I'm only able to successfully do get requests. If I try to delete an opportunities tags by supplying a key and value like the documentation suggests it always gives me an error code 417. I've also tried seeing if it wanted it as a param in the path but also no luck.

payload = {"TAG_NAME":"Warehouse"}

opp_tag = requests.delete("https://api.insightly.com/v3.1/Opportunities/number/Tags", data=json.dumps(payload), headers=my_headers)

Does anyone have any answers to this? I'm fairly new to api's in general so help would be much apreciated.

1 Answers1

0

I was able to figure this out. Hopes this helps anyone else who has issue with insightly. Anyways, it looks like Insightly doesn't like it when you use requests.delete or post when you interact with the api. That seems to be the only issue, everything else is just a normal api call

import requests
import json


def del_tag(tag_name, opp_id):

  url = f"https://api.na1.insightly.com/v3.1/Opportunities/{opp_id}/Tags"

  payload = json.dumps({
    "TAG_NAME": f"{tag_name}"
  })
  headers = {
    'Authorization': 'Basic {key}',
    'Content-Type': 'application/json',
    'Cookie': 'snaptid=sac1prdc01wut07'
  }

  response = requests.request(f"DELETE", url, headers=headers, data=payload)