cancel
Showing results for 
Search instead for 
Did you mean: 

RESTful API BO 4.3 - 415 Unsupported Media Error From Creating Crystal Report Schedule

former_member815110
Discoverer
0 Kudos

BO 4.3.

I'm trying to add a schedule to an existing crystal report using the REST API. I'm able to log into the server and retrieve a token, retrieve documents and their schedules along with details, but I'm unable to send a post request to add a new one. I get 415 error - unsupported media type. I was able to post a new publication successfully but we are needing to add new schedules to crystal reports. SAP documentation seems specific to Webi reports, but SAP support says this is also possible for crystal; however, they haven't been able to tell me what I'm doing wrong yet.

Referencing SAP's own documentation, I used their exact sample for creating a schedule with email destination located here: Example - Mail Destination for a Hourly Schedule.

I tried this for a crystal and webi report, and I still get the same 415 error. Could someone please tell me what I'm doing wrong?

Here is my code written in python:

Token Retrieval:

import pandas as pd<br>import numpy as np<br>import requests<br>import json<br>
# retrieve login token<br>url = 'http://redacted:8080/biprws/logon/long'<br><br>headers = {<br>    "Accept": "application/json",<br>    "X-SAP-TRUSTED-USER": "redacted",<br>    "Content-Type": "application/xml"<br>}<br>body = f"""<br><attrs xmlns="http://www.sap.com/rws/bip"><br>    <attr name="password" type="string">redacted</attr><br>    <attr name="clientType" type="string">user</attr><br>    <attr name="auth" type="string" possibilities="secEnterprise,secLDAP,secWinAD,secSAPR3">secEnterprise</attr><br>    <attr name="userName" type="string">redacted</attr><br></attrs><br>"""

res = requests.post(url, body, headers=headers)<br><br>res = json.loads(res.text)<br>token = res['logonToken']

Schedule retrieval:

headers = {<br>    "Accept":"application/xml",<br>    "X-SAP-LOGONTOKEN":f"{token}"<br>}<br>url = f'http://redacted:6405/biprws/raylight/v1/documents/3127507/schedules/3361229'<br>resp = requests.get(url, headers=headers)<br>print(resp.text)

Response:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<schedule>
    <id>3361229</id>
    <name>RevintHB-Account</name>
    <format type="txt"/>
    <status id="9">Recurring</status>
    <updated>2022-04-06T21:40:54.875Z</updated>
    <destination keepInstanceInHistory="true">
        <useSpecificName fileExtension="false">%SI_NAME%_%SI_STARTTIME%.txt</useSpecificName>
        <mail>
            <from>redacted</from>
            <to>redacted</to>
            <cc>redacted</cc>
            <subject>%SI_NAME%</subject>
            <message></message>
            <addAttachment>true</addAttachment>
        </mail>
    </destination>
    <weekly retriesAllowed="0" retryIntervalInSeconds="1800">
        <startdate>2022-04-30T16:00:00.000Z</startdate>
        <enddate>2031-03-10T18:38:00.000Z</enddate>
        <saturday>saturday</saturday>
    </weekly>
    <serverGroup id="0" required="false"/>
</schedule>

Here is my post attempt:

url = 'http://redacted:8080/biprws/v1/documents/3127507/schedules'<br><br>headers = {<br>    "Accept":"application/json",<br>    "X-SAP-LOGONTOKEN":f"{token}",<br>    "Content-Type": "application/xml"<br>}<br><br>body = """<br><schedule><br>    <name>RevintHB-Account</name><br>    <format type="csv"/><br>    <status id="9">Recurring</status><br>    <destination keepInstanceInHistory="true"><br>        <useSpecificName fileExtension="false">%SI_NAME%_%SI_STARTTIME%.txt</useSpecificName><br>        <mail><br>            <from>redacted@myorg.org</from><br>            <to>redacted@myorg.org</to><br>            <cc>redacted@myorg.org</cc><br>            <subject>%SI_NAME%</subject><br>            <message>hello this is the message</message><br>            <addAttachment>true</addAttachment><br>        </mail><br>    </destination><br>    <hourly retriesAllowed="0" retryIntervalInSeconds="1800"><br>        <startdate>2022-04-30T16:00:00.000Z</startdate><br>        <enddate>2031-03-10T18:38:00.000Z</enddate><br>        <hour>1</hour><br>        <minute>0</minute><br>    </hourly><br></schedule><br>"""<br>resp = requests.post(url, body, headers=headers)<br>print(resp)

Any help is appreciated!

Accepted Solutions (0)

Answers (0)