Author Topic: CM 11.03.x API issues  (Read 137 times)

Offline leonardo.silva

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
CM 11.03.x API issues
« on: January 04, 2018, 12:05:19 PM »
Hello,

I'm having issues with API since last updated version of CM 11.03.06.

In the past, this code (wrote in python) worked fine in a loop:

delete_filter = "%s/media?filters={'id':{'values':[%s],'comparator':'eq'}}" % (rest_url, media['id'])
req2 = self.http_connection.urlopen('DELETE', delete_filter, headers=self.http_headers)

now it doesn't work, but ok, i'm trying to follow API docs to delete many media items by filters as follow:

API doc exemple: {'id' : {'values':[2,10,14], comparator : 'in'}}

My code without any loop:
delete_filter = "%s/media?filters={'id':{'values':%s,'comparator':'in'}}" % (rest_url, image_ids)
req = self.http_connection.urlopen('DELETE', delete_filter, headers=self.http_headers)

Obs: image_ids get all the media ids based on media category and append the id in a python dict.

Running this code, API doesn't show any error or warn on log, so, i suppose all media was deleted by filter, but no! all the medias selected kept as is.

All these codes was executed with an administrator account.

Could you help me?

Thank you,

Offline leonardo.silva

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
Re: CM 11.03.x API issues
« Reply #1 on: January 04, 2018, 12:19:06 PM »
just in case:
this filter "%s/media?filters={'id':{'values':[%s],'comparator':'eq'}}" % (rest_url, media['id']) works fine when I use the GET method, but doesn't with DELETE.

Offline SHAQU

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
    • View Profile
Re: CM 11.03.x API issues
« Reply #2 on: January 25, 2018, 01:10:48 PM »
Will you also update python?
For example, after updating python from 2.6.2 to 2.7.11 (attached to Scala CM 11.03.06), one of the scripts written in python has stopped working. I found that in the new version there is no ZSI catalog, which in version 2.6.2 is in the path: C: \ Program Files (x86) \ Python26 \ Lib \ site-packages \
I copied this directory to Python 2.7.11 to the location: C: \ Python27 \ Lib \ site-packages
Pyhona's script started working as before
This solution may also help you