0

Trying to call API from : here

In order to delete multiple images, I must pass a string with all images ID. But I don't know how to generate good string

At the begining I have a list of string and I want to have only string like this:



DELETE https://westus.api.cognitive.microsoft.com/customvision/v3.0/training/projects/64b822c5-8082-4b36-a426-27225f4aa18c/images?imageIds=[

  "e31a14ab-5d78-4f7b-a267-3a1e4fd8a758",  #I need string like this

  "cf0f83fb-ebaa-4b25-8e34-613a6a0b8a12"

]

I tryed this:

inputs=['a','b','c']  #input example
','.join(inputs)

conn.request("DELETE", "/customvision/v3.0/training/projects/"+model_id+"/images?imageIds={"+','.join(inputs)+"}&%s" % params, "{body}", headers)

But its doesnt work. My code is working when I delete images 1 by 1 but I now need to find the good way to generate the string

I also tryed to cast it as array:

myarray = np.array(inputs)
conn.request("DELETE", "/customvision/v3.0/training/projects/"+model_id+"/images?imageIds={"+myarray+"}&%s" % params, "{body}", headers)

Error message:

TypeError: ufunc 'add' did not contain a loop with signature matching types dtype('<U91') dtype('<U91') dtype('<U91')

API doc: doc

akhetos
  • 686
  • 1
  • 10
  • 31
  • But according to API documentation `imageIds` is an array so why're you passing as a string? – Adam Strauss Sep 21 '20 at 14:07
  • because based on this doc (https://westeurope.dev.cognitive.microsoft.com/docs/services/Custom_Vision_Training_3.0/operations/5c771cdcbf6a2b18a0c3b800) I should be capable to input string. I have been able to make it work! I just had to delete the ` { ` :D – akhetos Sep 21 '20 at 14:23
  • No dear you're not capable to enter string in `imagesIds` – Adam Strauss Sep 21 '20 at 14:26

0 Answers0