Question

/api/2/deletions/users ignore_invalid_ids not working

  • 11 June 2024
  • 1 reply
  • 39 views

I am running the following:

 

import requests
import json
from requests.auth import HTTPBasicAuth

url = "https://amplitude.com/api/2/deletions/users"

payload = json.dumps({
"user_ids": [
"this_one_exists", "does_not_exist"
],
"requester": "test@gmail.com",
"ignore_invalid_ids": True,
})
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
auth = HTTPBasicAuth('API_KEY', 'SECRET_KEY')
response = requests.request("POST", url, headers=headers, data=payload, auth=auth)

print(response.text)

 

Notice that in user IDs, one value does exist on Amplitude, and the other doesn’t. I get the following response:

 

{'error': {'http_code': 400,
'type': 'invalid',
'message': 'Invalid definition',
'metadata': {'details': 'invalid amplitude_ids and/or user_ids given for app [%s]. invalid amplitude ids: [%s], invalid user_ids: [%s]'}}}

 

My understanding is that the first should be added to the batch queue, and the second should be reported as an invalid ID. Am I doing something wrong here? Thank you!


1 reply

Userlevel 5
Badge +9

Hello @Justin Trenor hope you are well!

 

Could you try the following call, please? This call worked for my personal project. 

import requests
import json

url = "https://amplitude.com/api/2/deletions/users"

payload = json.dumps({
"user_ids": [
"this_one_exists", "does_not_exist"
],
"ignore_invalid_id": "true",
"requester": "employee@yourcompany.com"
})
headers = {
'Content-Type': 'application/json',
'Authorization': 'Basic Auth'
}

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

print(response.text)

 

Reply