How to use ask_smapi_sdk for Python to upload a catalog

64 views Asked by At

I am trying to upload some catalogs for a music skill. I am using the ask_smapi_sdk installed from pip

upload_request = catalog_v1.create_content_upload_url_request.CreateContentUploadUrlRequest()
    res = client.generate_catalog_upload_url_v1(catalog_id, upload_request)
    
    upload_response = requests.put(res.presigned_upload_parts[0].url, data=json.dumps(cat))
    req = upload.complete_upload_request.CompleteUploadRequest()
    res = client.complete_catalog_upload_v0(catalog_id, upload_response.headers['eTag'], req, full_response=True)

When I run this code it gives me the very useful error ask_sdk_model_runtime.exceptions.ServiceException: Server cannot process the request due to a client error.

Am I doing something obvious wrong? How do I make it work?

1

There are 1 answers

0
Will_A On

Depending on the ASK SDK for python version used, I would recommend checking the ASK SMAPI API reference for create_content_upload_url_request as i understand on latest version it follows this format for your upload_request operation

    ask_smapi_model.v1.catalog.create_content_upload_url_response.
CreateContentUploadUrlResponse(url_id=None, pre_signed_upload_parts=None)

Similarly for response (res)

   ask_smapi_model.v1.catalog.create_content_upload_url_response.
CreateContentUploadUrlResponse(url_id=None, pre_signed_upload_parts=None)

Please refer to ASK SMAPI catalog upload reference for python for properly uploading music catalog using pythonhere

Hope this information helps.