Hi All
I am Looking to delete the 20 batches at a time and also to delete the all batches in a certain timeperiod. Below is the process Which I followed Can someone help me on this:
Step-1:I tried to find the list of Batches with Get Curl and 20 list of batches I got.
Step-2:When am trying to delete those batches at a time am getting response success in API Call,but in UI the Batches are not getting deleted.
Step-3:I can able to delete the single batch in API and it is working on UI also.
Multiple Batches Body:
Post:https://platform.adobe.io/data/foundation/import/batches
Method-1:
{
"datasetId":"XXXXXXXXX",
"batches":
[
{"BATCH_ID":"01HHYBEN2AV7WYXW4G4ZZJXMTX"},
{"BATCH_ID":"01HHYB9W13MNKN3ZKF21F6J1TF"},
{"BATCH_ID":"01HHYB482FVA8G93E114VRCAXR"},
{"BATCH_ID":"01HHYAY3XFAANZ93QKF6TQ21FB"},
{"BATCH_ID":"01HHYAX1EEG0GP3ANR9DNQZFA7"},
{"BATCH_ID":"01HHYAS3E283Q60BHMAHN7286K"},
{"BATCH_ID":"01HHYANHPDZV0ERPHW6JZSF3XZ"},
{"BATCH_ID":"01HHYAMAN5WQ5TPBWWFV95A9FH"},
{"BATCH_ID":"01HHYAHHXJ0QRV3TCCBYJSF5EX"},
{"BATCH_ID":"01HHYACGKST6Q46QE4A8SDTCZ8"},
{"BATCH_ID":"01HHYA7VM0WXP4FH1VY7JCJ1J3"},
{"BATCH_ID":"01HHYA4JKPDVK343XHKFQEEWE6"},
{"BATCH_ID":"01HHY9YYCW1AG3ZAMRH260JX55"},
{"BATCH_ID":"01HHY9PZZ35FYHQ147AF34PFGC"},
{"BATCH_ID":"01HHY9SQ402WDMXXJS9A802DRX"},
{"BATCH_ID":"01HHY9MJPDT6FT3T6FFW2PF34M"},
{"BATCH_ID":"01HHY9HA1W5W91NMGBXAW0139A"},
{"BATCH_ID":"01HHY9G92WSYM0YE2V84HFA7MS"},
{"BATCH_ID":"01HHY9CKKMYNTD5MYT5ZA5MHZ5"},
{"BATCH_ID":"01HHY9AARVRXJZDYHE6ATQGHPA"}
]
}
Thanks,
Nikhil.N
Solved! Go to Solution.
Views
Replies
Total Likes
Hey @NikhilKumarNa
I did have a script handy but did not get a chance to test it out.
If you are in a hurry. Try the below script. It is in python. As I said, havent given it a shot yet but should work.
import requests
import json
# API endpoints
get_batches_endpoint = 'https://example.com/api/batches'
delete_batch_endpoint = 'https://example.com/api/delete_batch/'
# OAuth token (replace with your actual token)
oauth_token = 'your_oauth_token_here'
# Headers with OAuth token
headers = {
'Authorization': f'Bearer {oauth_token}'
}
# Function to get batches
def get_batches(url):
response = requests.get(url, headers=headers)
if response.status_code == 200:
return json.loads(response.text)
else:
print(f"Error: {response.status_code}")
return []
# Function to delete a batch
def delete_batch(batch_id):
response = requests.delete(f"{delete_batch_endpoint}{batch_id}", headers=headers)
if response.status_code == 200:
print(f"Batch {batch_id} deleted successfully")
else:
print(f"Error deleting batch {batch_id}: {response.status_code}")
# Main process
batches = get_batches(get_batches_endpoint)
for batch in batches:
batch_id = batch.get('batch_id') # Assuming the batch ID is under the key 'batch_id'
if batch_id:
delete_batch(batch_id)
Hey @NikhilKumarNa
Am I missing something in the 2nd method you are using ? You do not have an action in the multiple batch payload so AEP doesn't know what to do with the request.
Let me know if adding action helps else we can explore further.
Cheers,
Abhinav
Sorry I missed to add here there should be action=Revert in the curl endpoint url.
Hey @Nikhil70326
I looked into the api endpoint. Doesn't look like you can delete multiple batches using one API call.
You can write a script to read the batch ids and trigger the endpoint for each separately.
Cheers,
Abhinav
Is it Possible to write a script in between Time period(StartDate-End Date) to delete the batches .If Yes
Could you Please provide the sample code here.
Regards,
Nikhil.N
Have not given it a shot yet but should be able to provide one tomorrow some time.
Cheers,
Abhinav
Hi abhinavbalooni
Did you get chance to work on script.
Regards,
Nikhil.N
Hey @NikhilKumarNa
I did have a script handy but did not get a chance to test it out.
If you are in a hurry. Try the below script. It is in python. As I said, havent given it a shot yet but should work.
import requests
import json
# API endpoints
get_batches_endpoint = 'https://example.com/api/batches'
delete_batch_endpoint = 'https://example.com/api/delete_batch/'
# OAuth token (replace with your actual token)
oauth_token = 'your_oauth_token_here'
# Headers with OAuth token
headers = {
'Authorization': f'Bearer {oauth_token}'
}
# Function to get batches
def get_batches(url):
response = requests.get(url, headers=headers)
if response.status_code == 200:
return json.loads(response.text)
else:
print(f"Error: {response.status_code}")
return []
# Function to delete a batch
def delete_batch(batch_id):
response = requests.delete(f"{delete_batch_endpoint}{batch_id}", headers=headers)
if response.status_code == 200:
print(f"Batch {batch_id} deleted successfully")
else:
print(f"Error deleting batch {batch_id}: {response.status_code}")
# Main process
batches = get_batches(get_batches_endpoint)
for batch in batches:
batch_id = batch.get('batch_id') # Assuming the batch ID is under the key 'batch_id'
if batch_id:
delete_batch(batch_id)
Views
Replies
Total Likes
@NikhilKumarNa - Did the Script work for you?
Views
Replies
Total Likes
Python Script got worked, to delete all the batches from the dataset.
Regards,
Nikhil.N
Hey @Nikhil70326
Great news !
Could you mark the response as correct reply so that it helps other folks as well in the future.
Cheers,
Abhinav
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies