List of string to one string to call an API

76 Views Asked by At

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

0

There are 0 best solutions below