Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSC.SubscriptionItem, Payload is either malformed or incomplete. (0x5CE10192 : Specifying subscription attachments not allowed.) #1430

Closed
gdrau opened this issue Jul 29, 2024 · 11 comments
Labels
help wanted A user needs help, may be a mistake, a bug or a feature request

Comments

@gdrau
Copy link

gdrau commented Jul 29, 2024

Hello, I'm trying to create a subscription for a user on a view. I put this piece of code,
schedule_id = '60c392fc-d902-44b0-92cf-cfa3b512630f'
user_id = df[0].values[i]
# Create the new SubscriptionItem object with variables from above.
new_sub = TSC.SubscriptionItem('EssaiGD', schedule_id, user_id, target)

    # (Optional) Set other fields. Any of these can be added or removed.
    new_sub.attach_image = True
    new_sub.attach_pdf = True
    new_sub.message = "You have an alert!"
    new_sub.page_orientation = TSC.PDFRequestOptions.Orientation.Portrait
    new_sub.page_size_option = TSC.PDFRequestOptions.PageType.A4
    new_sub.send_if_view_empty = True

    # Create the new subscription on the site you are logged in.
    new_sub = server.subscriptions.create(new_sub)

I launch it and when I have the error it gives me 0x5CE10192 : Specifying subscription attachments not allowed.

THanks

Version :
Product version: 2024.2.0
REST API version: 3.23
Build number: 20242.24.0711.1807
Python 3.10.6

@gdrau gdrau changed the title TSC.SubscriptionItem, 0x5CE10192 : Specifying subscription attachments not allowed TSC.SubscriptionItem, Payload is either malformed or incomplete. (0x5CE10192 : Specifying subscription attachments not allowed.) Jul 29, 2024
@jorwoods
Copy link
Contributor

From the REST API documentation:

If subscriptions to attachments are disabled in Tableau server or site settings, then making a request that sets attachImage to false will cause an error.

@gdrau
Copy link
Author

gdrau commented Jul 30, 2024

the parameters are true and not false in my script. So when I manually create the subscription or when I use a request it works. So I don't understand why it doesn't work

@gdrau
Copy link
Author

gdrau commented Jul 30, 2024

image

@jorwoods
Copy link
Contributor

What happens if you set image to True, pdf to False, and remove the pdf specific options? Try the simplest case first.

@gdrau
Copy link
Author

gdrau commented Jul 30, 2024

image
the same

@gdrau
Copy link
Author

gdrau commented Jul 30, 2024

image

@gdrau
Copy link
Author

gdrau commented Jul 30, 2024

image

@gdrau
Copy link
Author

gdrau commented Aug 26, 2024

?? Help me :-)

@jorwoods
Copy link
Contributor

jorwoods commented Aug 27, 2024

My minimally reproducible example works. edit: Also attaching image. Still works.

# /// script
# requires-python = ">=3.10
# dependencies = [
#   "tableauserverclient>=0.32.0",
#   "python-dotenv"
# ]
# ///

import os

from dotenv import load_dotenv
import tableauserverclient as TSC

load_dotenv()

auth = TSC.PersonalAccessTokenAuth(
    token_name=os.environ["TABLEAU_TOKEN_NAME"],
    personal_access_token=os.environ["TABLEAU_PAT"],
    site_id=os.environ["TABLEAU_SITE"]
)

server = TSC.Server(os.environ["SERVER_ADDRESS"], use_server_version=True)
with server.auth.sign_in(auth):
    workbook = server.workbooks.filter(name="Team Metrics")[0]
    target = TSC.Target(workbook.id, "workbook")

    # Pick a random schedule for testing purposes
    sched = next(s for s in TSC.Pager(server.schedules) if s.schedule_type == TSC.ScheduleItem.Type.Subscription)
    
    sub = TSC.SubscriptionItem("message", schedule_id=sched.id, user_id=server.user_id, target=target)
    sub.attach_image = True
    sub.attach_pdf = True
    sub.page_orientation = TSC.PDFRequestOptions.Orientation.Portrait
    sub.page_size_option = TSC.PDFRequestOptions.PageType.A4
    sub.send_if_view_empty = True
    
    sub = server.subscriptions.create(sub)

@jacalata jacalata added the help wanted A user needs help, may be a mistake, a bug or a feature request label Sep 20, 2024
@jacalata
Copy link
Contributor

@gdrau what API version are you using in your script? This error message will also be returned if you are specifying an API version below 3.5, when the feature was implemented.

@jacalata
Copy link
Contributor

jacalata commented Oct 4, 2024

I created a sample for subscriptions and verified that it succeeds with the current server version, and fails using 2.4. #1487

@jacalata jacalata closed this as completed Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted A user needs help, may be a mistake, a bug or a feature request
Projects
None yet
Development

No branches or pull requests

3 participants