I have a CSV of "New Contact IDs" that need to be merged with the duplicate "Old Contact IDs", so I am iterating through these to bulk update by replacing the ID in the URL and the vidToMerge ID. However, I keep getting 404 and 405 errors saying the resource is not found. Here is what I have:
import csv
import pandas as pd
from pandas import *
# reading CSV file
data = read_csv("sample_import.csv")
# converting column data to list
main_contacts = data['New_Contact_ID'].tolist()
contacts_to_merge = data['Old_Contact_ID'].tolist()
for main_id in main_contacts:
endpoint = requests.get('https://api.hubapi.com/contacts/v1/contact/merge-vids/{}/?hapikey=xxxx'.format(id))
for old_id in contacts_to_merge:
{
"vidToMerge": old_id
}
You are making a get request to a post endpoint, you need to modify your code to follow the request's post documentation. The reason you are getting a 404 is because that endpoint does not exist with a get method, it only exists with a post method.
#Instead of this
endpoint = requests.get('https://api.hubapi.com/contacts/v1/contact/merge-vids/{}/?hapikey=xxxx'.format(id))
#Format your request like this, though you will need to change your loops, and how they nest
endpoint = requests.post('https://api.hubapi.com/contacts/v1/contact/merge-vids/{}/?hapikey=xxxx'.format(id), data={"vidToMerge": 1343774})
✔️ Was I able to help answer your question? Help the community by marking it as a solution.
You are making a get request to a post endpoint, you need to modify your code to follow the request's post documentation. The reason you are getting a 404 is because that endpoint does not exist with a get method, it only exists with a post method.
#Instead of this
endpoint = requests.get('https://api.hubapi.com/contacts/v1/contact/merge-vids/{}/?hapikey=xxxx'.format(id))
#Format your request like this, though you will need to change your loops, and how they nest
endpoint = requests.post('https://api.hubapi.com/contacts/v1/contact/merge-vids/{}/?hapikey=xxxx'.format(id), data={"vidToMerge": 1343774})
✔️ Was I able to help answer your question? Help the community by marking it as a solution.