Auto adding powerpoint to the CMS using the APi - problems

Hi, I’m using a modified version of the API upload code created by @Alex but to auto upload a powerpoint rather than a video.

The problem comes when executing the line:

response, status, code, message, content = api.callMethod(‘LibraryMediaAdd’, params)

as I get the following xml

<rsp status="error">
  <error code="20" message="No Module of this type found."/>
</rsp>

From what I can see, code 20 is not in the documentation . also, the parameter “permissionId” is not defined in the docs either.
For reference, the documentation url I’m looking at is: http://xibo.org.uk/manual/en/api_library.html

My code fragment with the params is below:

# Now the file is uploaded, and the old file is deleted,
# we need to add the newly uploaded file to the CMS Library
params = [('fileId', uploadId),
          ('type', 'ppt'),
          ('name', mediaName),
          ('duration', '0'),
#          ('permissionId','1'),
          ('fileName',os.path.basename(fileToUpload))
         ]
         
print 'fileId : %s' % uploadId
print 'name : %s' % mediaName
print 'fileName : %s' % os.path.basename(fileToUpload)
response, status, code, message, content = api.callMethod('LibraryMediaAdd', params)

print 'content : %s' % content
# Get the ID of the file we just added
mediaId = api.parseID(content,'media')

# Now mediaID contains the library media ID of our freshly uploaded video
print "Adding new media with ID %s" % mediaId

Please excuse the formatting craziness. I’m note familiar with the editor

Could you please help with where this may be going wrong. The previous parts of Alex’s script of identifying old media and deleting is working correctly as confirmed when looking in the xibo cms. Also, the Oauth2 part is working and registered in the server. I am wondering if the “params” content is correct for a powerpoint file and if the extension pptx is accepted. Also, how do I determine if the foregoing upload has worked. It does return, a valid looking mediaId so I think that is ok.

Thanks

Simon

I’m not really familiar with python syntax i’m afraid, so Alex may need to comment - however I would have thought that your type parameter should be powerpoint rather than ppt.

I also took the liberty of formatting your article :smile:

1 Like

Hi Dan,

Thanks for the reformatting and the hint

The parameter changes seems to have worked. The duration of 0 threw an error which is from the example so I changed that to 30secs and all is good. The “permisionId” parameter was omitted in my script and it all still worked. That might be something to edit in @Alex’s original example.

You might want to change the doc in http://xibo.org.uk/manual/en/api_library.html as it has the powerpoint parameter as “ppt”.

We can close this topic from my point of view.

thanks for the assistance.

1 Like