<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Generate PDF from View in REST API in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274794#M52707</link>
    <description>&lt;P&gt;Hi cwue,&lt;BR /&gt;
Thanks for this ... is this your internal git repo? or any chance its public?&lt;BR /&gt;
I'm a splunk newbie just hacking my way through automating some dashboards. I've done python for a long time (and love it). Any pointers towards  python/splunk snipets/code appreciated.&lt;BR /&gt;
Regards,&lt;BR /&gt;
Craig&lt;/P&gt;</description>
    <pubDate>Tue, 30 Oct 2018 17:12:33 GMT</pubDate>
    <dc:creator>curtin1061</dc:creator>
    <dc:date>2018-10-30T17:12:33Z</dc:date>
    <item>
      <title>How to generate PDF from view in REST API?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274783#M52696</link>
      <description>&lt;P&gt;I am using Splunk 6.1.1 and currently have a form that takes an integer input (foo) and timerange. The URL for this view after entering the values is &lt;A href="https://splunk/app/app_name/view_name?earliest=-30d&amp;amp;latest=now&amp;amp;form.foo=1#" target="_blank" rel="noopener"&gt;https://splunk/app/app_name/view_name?earliest=-30d&amp;amp;latest=now&amp;amp;form.foo=1#&lt;/A&gt;. I then generate a PDF from this page. Thing is, I need this form for about 650 instances of foo, and I'd like to run it once a month.&lt;/P&gt;
&lt;P&gt;I can't schedule the view since it requires input, and I refuse to create 650 instance of the form without input. My hope is to create a python or ruby script that calls this view with the required input, generates a PDF from the output, and gives me the document metadata so I can store elsewhere. Is this a thing? Looking through the API docs, I see lots for scheduled searches, but this isn't a scheduled search. Any assistance would be much appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 14:08:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274783#M52696</guid>
      <dc:creator>kknopp</dc:creator>
      <dc:date>2023-01-31T14:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: Generate PDF from View in REST API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274784#M52697</link>
      <description>&lt;P&gt;There is a &lt;CODE&gt;/services/pdfgen/render&lt;/CODE&gt; endpoint, but it doesn't appear to be documented. You might be able to reverse-engineer how to call it from &lt;CODE&gt;$SPLUNK_HOME/share/splunk/search_mrsparkle/exposed/js/util/pdf_utils.js#downloadReportFromXML()&lt;/CODE&gt;, that's what gets called underneath when you click the &lt;CODE&gt;Export PDF&lt;/CODE&gt; button.&lt;/P&gt;</description>
      <pubDate>Sat, 06 Feb 2016 22:15:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274784#M52697</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2016-02-06T22:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: Generate PDF from View in REST API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274785#M52698</link>
      <description>&lt;P&gt;interesting. I'll give it a shot, and let you know what I find. Thank you Martin.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2016 14:38:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274785#M52698</guid>
      <dc:creator>kknopp</dc:creator>
      <dc:date>2016-02-08T14:38:03Z</dc:date>
    </item>
    <item>
      <title>Re: Generate PDF from View in REST API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274786#M52699</link>
      <description>&lt;P&gt;The &lt;CODE&gt;/services/pdfgen/render/&lt;/CODE&gt; endpoint takes a view [as answered here: &lt;A href="https://answers.splunk.com/answers/223655/can-i-export-pdf-via-rest.html"&gt;https://answers.splunk.com/answers/223655/can-i-export-pdf-via-rest.html&lt;/A&gt;], but luckily also a &lt;CODE&gt;input-dashboard-xml&lt;/CODE&gt; input, which accepts xml-dashboards - as long as all tokens/variables are resolved (!).&lt;/P&gt;

&lt;P&gt;To generate a ton of different reports based on the same view/dashboard but different search parameters I wrote a python script.&lt;/P&gt;

&lt;P&gt;Using this script all you have to do is&lt;BR /&gt;
 - save the dasboard code as .xml-file&lt;BR /&gt;
 - figure out for which report you want to replace which tokens and have a list of those tokens for every report.&lt;BR /&gt;
 - hand over a JSON List with tokens and their respective values&lt;BR /&gt;
 &lt;CODE&gt;{"tokenlist":[{'token':'$example$' 'value':'value for individual search'}, {'token':'$example2$' 'value':'searchstring'}]&lt;/CODE&gt;&lt;BR /&gt;
 - run the script which will send the compatible dashboard code to the API and download the resulting pdf report&lt;/P&gt;

&lt;P&gt;So my &lt;CODE&gt;generateReport(tokenlist)&lt;/CODE&gt; function looks like this: &lt;BR /&gt;
(Disclaimer: &lt;EM&gt;this is simplified to get the concept across- I stripped error detection for invalid reports, logging, metadata creation and the like - which is crucial if you plan on automatically mailing those reports&lt;/EM&gt;)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;# import requests

with open('dashboardFile.xml','rb') as XMLfile:
    XMLDashboard =XMLfile.read().replace('\n', '')
    XMLDashboard = XMLDashboard.replace('&amp;lt;', '%26lt%3B')  # otherwise the API will complain

# Replace all tokens in the XMLCode
for t in tokenlist:
    XMLDashboard = XMLDashboard.replace(t['token'], t['value'])

# Send XML code to endpoint, answer should be a pdf file
r = requests.get('https://splunkhost:8089/services/pdfgen/render', auth=(splunkuser, splunkpass), params={'input-dashboard-xml':XMLDashboard,'paper-size':'a4-landscape'})

if r.status_code == 200:
    with open('report_file.pdf', 'wb') as pdffile:
        pdffile.write(r.content)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 17 Apr 2016 17:34:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274786#M52699</guid>
      <dc:creator>cwue</dc:creator>
      <dc:date>2016-04-17T17:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: Generate PDF from View in REST API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274787#M52700</link>
      <description>&lt;H2&gt;This works great.  Thanks a lot, cwue. Those who don't have access to "requests" library can use curl command like the following:&lt;/H2&gt;

&lt;P&gt;import subprocess&lt;BR /&gt;
file_out = "/home/splunk/pdf_dashboards/yourpdfile.pdf" &lt;/P&gt;

&lt;H2&gt;subprocess.call(["curl","-G", "-sku", "your_user_name:your_password","-k", Url, "--data-urlencode", "input-dashboard-xml=" + XMLDashboard,"-d","namespace=yourAppName", "-d","paper-size=a4-landscape"], stdout=file_out)&lt;/H2&gt;

&lt;P&gt;if you are using "--data-urlencode" then you don't have to  use the following two lines:&lt;BR /&gt;
     XMLDashboard=XMLfile.read().replace('\n', '')&lt;BR /&gt;
     XMLDashboard = XMLDashboard.replace('&amp;lt;', '%26lt%3B')  # otherwise the API will complain&lt;/P&gt;

&lt;P&gt;Good Luck and Thanks to cwue once again.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:51:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274787#M52700</guid>
      <dc:creator>anwarmian</dc:creator>
      <dc:date>2020-09-29T12:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: Generate PDF from View in REST API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274788#M52701</link>
      <description>&lt;P&gt;Thanks both for this help - however, if you want to do it from a shell script, this works:&lt;BR /&gt;
- save dashboard as "mydash.xml" with appropriate parameters/timeline set&lt;BR /&gt;
- run this curl command:&lt;BR /&gt;
- &lt;CODE&gt;curl -G -sku admin:${mypass}  "https://localhost:8089/services/pdfgen/render" --data-urlencode "input-dashboard-xml=$(cat mydash.xml)" -d namespace=search -d paper-size=a4-landscape &amp;gt; mydash.pdf&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 13:24:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274788#M52701</guid>
      <dc:creator>JohnRiddoch</dc:creator>
      <dc:date>2017-06-16T13:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: Generate PDF from View in REST API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274789#M52702</link>
      <description>&lt;P&gt;Were any of you successful in creating a pdf in linux using REST API and emailing to Windows box and check if the pdf show properly?  When I created a pdf using the above method in Linux (using python) it looks great in linux but after sending it to Windows via email Windows displays the pdf with blank pages.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Oct 2017 16:48:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274789#M52702</guid>
      <dc:creator>anwarmian</dc:creator>
      <dc:date>2017-10-30T16:48:56Z</dc:date>
    </item>
    <item>
      <title>Re: Generate PDF from View in REST API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274790#M52703</link>
      <description>&lt;P&gt;Hi @anwarmian and @cwue,&lt;/P&gt;

&lt;P&gt;By using this approach doesn it resolve the problems with pdf renderinng. &lt;BR /&gt;
Does it retain the same color codes which are used in the dashbaord&lt;BR /&gt;
Does it retain the same spacing and panels for page as that of the dashboard ?&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2018 10:22:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274790#M52703</guid>
      <dc:creator>surekhasplunk</dc:creator>
      <dc:date>2018-01-17T10:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: Generate PDF from View in REST API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274791#M52704</link>
      <description>&lt;P&gt;Thanks cwue! In case anyone else gets errors saying that it couldn't find the end of a start tag, adding XMLDashboard=XMLDashboard.replace(' ', '%20') should work!&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jun 2018 15:49:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274791#M52704</guid>
      <dc:creator>rblack88</dc:creator>
      <dc:date>2018-06-25T15:49:30Z</dc:date>
    </item>
    <item>
      <title>Re: Generate PDF from View in REST API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274792#M52705</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;
Does anyone have the full script/xml files needed  ... the reference link above is no longer valid.&lt;/P&gt;

&lt;P&gt;I'd love to see the python code, I'm not sure where I find the 'dashboardFile.xml' or what this file should look like.&lt;/P&gt;

&lt;P&gt;Python and curl examples appreciated.&lt;BR /&gt;
Craig&lt;/P&gt;</description>
      <pubDate>Mon, 29 Oct 2018 18:25:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274792#M52705</guid>
      <dc:creator>curtin1061</dc:creator>
      <dc:date>2018-10-29T18:25:06Z</dc:date>
    </item>
    <item>
      <title>Re: Generate PDF from View in REST API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274793#M52706</link>
      <description>&lt;P&gt;Hi curtin1061,&lt;/P&gt;

&lt;P&gt;it's been a while but I just checked our git and this is the relevant code of my program to download the dashboard as xml.&lt;BR /&gt;
    SplunkUsername, DashboardName, AppName and SessionKey are variables.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import io, requests, json
endpoint = 'https://splunkhost:8089/servicesNS/' + SplunkUsername + '/' + AppName + '/data/ui/views/' + DashboardName
    r = requests.get(endpoint, headers={'Authorization': 'Splunk ' + SessionKey}, params={'output_mode': 'json'}, verify=False)
    dashboardcode = r.json()['entry'][0]['content']['eai:data']

    with io.open('dashboard.xml', 'w', encoding='utf8') as f:
        f.write(dashboardcode)
    print("Saved dashboard.xml")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Oct 2018 19:36:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274793#M52706</guid>
      <dc:creator>cwue</dc:creator>
      <dc:date>2018-10-29T19:36:24Z</dc:date>
    </item>
    <item>
      <title>Re: Generate PDF from View in REST API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274794#M52707</link>
      <description>&lt;P&gt;Hi cwue,&lt;BR /&gt;
Thanks for this ... is this your internal git repo? or any chance its public?&lt;BR /&gt;
I'm a splunk newbie just hacking my way through automating some dashboards. I've done python for a long time (and love it). Any pointers towards  python/splunk snipets/code appreciated.&lt;BR /&gt;
Regards,&lt;BR /&gt;
Craig&lt;/P&gt;</description>
      <pubDate>Tue, 30 Oct 2018 17:12:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274794#M52707</guid>
      <dc:creator>curtin1061</dc:creator>
      <dc:date>2018-10-30T17:12:33Z</dc:date>
    </item>
    <item>
      <title>Re: Generate PDF from View in REST API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274795#M52708</link>
      <description>&lt;P&gt;I have not contributed to this repo in several months, but this might help you. &lt;A href="https://github.com/BryceKopan/SlackSplunkBot/blob/master/src/RESTSplunkMethods.py"&gt;https://github.com/BryceKopan/SlackSplunkBot/blob/master/src/RESTSplunkMethods.py&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Oct 2018 18:36:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274795#M52708</guid>
      <dc:creator>rblack88</dc:creator>
      <dc:date>2018-10-30T18:36:54Z</dc:date>
    </item>
    <item>
      <title>Re: Generate PDF from View in REST API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274796#M52709</link>
      <description>&lt;P&gt;HI , &lt;/P&gt;

&lt;P&gt;Understand that this rest api able to generate a pdf report , I am not sure where should i locate the script ? What if i want to schedule the export of pdf like daily monthly or weekly ? Should i do a scheduling of report from splunk and action behind is to run a scripts ? &lt;/P&gt;

&lt;P&gt;Any detailed steps for newbie ? &lt;/P&gt;

&lt;P&gt;Thanks in advance . &lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 04:45:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274796#M52709</guid>
      <dc:creator>Iriseng94</dc:creator>
      <dc:date>2019-05-15T04:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: Generate PDF from View in REST API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274797#M52710</link>
      <description>&lt;P&gt;HI ,&lt;/P&gt;

&lt;P&gt;Understand that this rest api able to generate a pdf report , I am not sure where should i locate the script ? What if i want to schedule the export of pdf like daily monthly or weekly ? Should i do a scheduling of report from splunk and action behind is to run a scripts ?&lt;/P&gt;

&lt;P&gt;Any detailed steps for newbie ?&lt;/P&gt;

&lt;P&gt;Thanks in advance . &lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 04:46:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274797#M52710</guid>
      <dc:creator>Iriseng94</dc:creator>
      <dc:date>2019-05-15T04:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: Generate PDF from View in REST API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274798#M52711</link>
      <description>&lt;P&gt;Does this work for dynamic token like &lt;CODE&gt;eval&lt;/CODE&gt;, &lt;CODE&gt;condition&lt;/CODE&gt;, &lt;CODE&gt;init&lt;/CODE&gt; Because tokens seems to be static replacement and must be passed/replaced before sending to api?&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jul 2019 08:22:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274798#M52711</guid>
      <dc:creator>conikhil</dc:creator>
      <dc:date>2019-07-20T08:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: Generate PDF from View in REST API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274799#M52712</link>
      <description>&lt;P&gt;Does this work for dynamic token like &lt;CODE&gt;eval&lt;/CODE&gt;, &lt;CODE&gt;condition&lt;/CODE&gt;, &lt;CODE&gt;init&lt;/CODE&gt; Because tokens seems to be static replacement and must be passed/replaced before sending to api?&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jul 2019 08:25:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/274799#M52712</guid>
      <dc:creator>conikhil</dc:creator>
      <dc:date>2019-07-20T08:25:19Z</dc:date>
    </item>
    <item>
      <title>Re: Generate PDF from View in REST API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/603093#M104957</link>
      <description>&lt;P&gt;this thread was very helpful in figuring out how to do this, however i did have some problems with the gt (&amp;gt;) and lt(&amp;lt;) operators in my searches.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;to work around this i wrapped them in CDATA tags:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;status&amp;lt;![CDATA[&amp;amp;gt;]]&amp;gt;199 AND status&amp;lt;![CDATA[&amp;amp;lt;]]&amp;gt;300&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if anyone else is interested, this is my "final" script:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import requests
import json
import os
from logzero import setup_logger

logger = setup_logger(name="logger", level=20)

splunk_endpoint = os.environ["SPLUNK_ENDPOINT"]
splunk_username = os.environ["SPLUNK_USERNAME"]
splunk_password = os.environ["SPLUNK_PASSWORD"]

with open("dashboard.xml", encoding="utf-8") as xml_file:
    xml_dashboard = xml_file.read()

with open("client_list.json", encoding="utf-8") as json_file:
    client_list = json.loads(json_file.read())

for client in client_list:

    logger.info(f"generating dashboard pdf for {client['name']} [{client['id']}]")

    # replace tokens in dashboard
    this_xml_dashboard = xml_dashboard.replace("--CLIENT--NAME--", client["name"])
    this_xml_dashboard = xml_dashboard.replace("--CLIENT--ID--", client["id"])

    # send xml dashboard to render endpoint
    render_url = f"{splunk_endpoint}/services/pdfgen/render"
    render_response = requests.post(
        render_url,
        auth=(splunk_username, splunk_password),
        params={
            "input-dashboard-xml": this_xml_dashboard.encode(),
            "paper-size": "a4-landscape",
        }
    )

    logger.info(f"render_response: {render_response.status_code}")

    # render endpoint returns a pdf
    if render_response.status_code == 200:
        outfile = (f"./output/dashboard-{client['name'].replace(' ', '_').lower()}.pdf")
        with open(outfile, "wb") as pdffile:
            pdffile.write(render_response.content)
        logger.info(f"wrote {filename} [{render_response.headers['Content-Length']} bytes]")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;hope this helps.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2022 22:57:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/603093#M104957</guid>
      <dc:creator>clamarkv</dc:creator>
      <dc:date>2022-06-23T22:57:41Z</dc:date>
    </item>
    <item>
      <title>Re: Generate PDF from View in REST API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/628964#M107917</link>
      <description>&lt;P&gt;I don't get why you open the XML file binary. I get string handling error if I do it so.&lt;/P&gt;&lt;P&gt;Bu I have another problem.&amp;nbsp; I open the xml file like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;replacelist = [("$pool_cust_lic_pool$", "{0}".format(customer_pool_name))]&lt;BR /&gt;&lt;BR /&gt;with open(DASHBOARD_FILE, 'r') as XMLfile:&lt;BR /&gt;XMLDashboard = XMLfile.read().replace('\n', '')&lt;BR /&gt;&lt;BR /&gt;for replacement in replacelist:&lt;BR /&gt;XMLDashboard = XMLDashboard.replace(replacement[0], replacement[1])&lt;BR /&gt;&lt;BR /&gt;r = requests.get(SPLUNKURL, auth=(SPLUNKUSER, SPLUNKPS),&lt;BR /&gt;params={'input-dashboard-xml': XMLDashboard, 'paper-size': 'a4-landscape'}, verify=False)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;part of the dashboard content:&lt;/P&gt;&lt;P&gt;&amp;lt;query&amp;gt; foreach "License-pool size in GB" [eval val2='&amp;amp;lt;&amp;amp;lt;FIELD&amp;amp;gt;&amp;amp;gt;']&amp;nbsp;&amp;lt;query&amp;gt;&lt;/P&gt;&lt;P&gt;#query is shorted. Since I have&amp;nbsp;&amp;nbsp;&amp;amp;lt;&amp;amp;lt; and&amp;nbsp;&amp;amp;gt;&amp;amp;gt; in my dashboard xml. I get the following error.&amp;lt;/query&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An error occured creating weekly reporting for pool auto_generated_pool_download-trial for cw 5&lt;BR /&gt;400 Unable to render PDF.&amp;lt;br/&amp;gt;&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;Bailing out of Integrated PDF Generation. Exception raised while preparing to render "Untitled" to PDF. StartTag: invalid element name, line 1, column 3533 (&amp;amp;lt;string&amp;amp;gt;, line 1)&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The column 3533 indicate the line&amp;nbsp;&amp;amp;lt;&amp;amp;lt;FIELD&amp;amp;gt;&amp;amp;gt; in the dashboard xml.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The dashboard works fine. I can request and convert it in pdf via curl&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;curl -X POST -u admin:Changeme1 -k '&lt;A href="https://localhost:8089/services/pdfgen/render?input-dashboard='license_test" target="_blank"&gt;https://localhost:8089/services/pdfgen/render?input-dashboard='license_test&lt;/A&gt;' &amp;amp;namespace=search &amp;amp;paper-size=a4-landscape' &amp;gt; test.pdf&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but it doesn't work via my python script&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 10:21:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/628964#M107917</guid>
      <dc:creator>splunknewbie</dc:creator>
      <dc:date>2023-01-31T10:21:40Z</dc:date>
    </item>
    <item>
      <title>Re: Generate PDF from View in REST API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/628984#M107919</link>
      <description>&lt;P&gt;I solve the problem after use the CDATA for my queries&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;![CDATA[ your search query here ]]&amp;gt;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 13:16:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-generate-PDF-from-view-in-REST-API/m-p/628984#M107919</guid>
      <dc:creator>splunknewbie</dc:creator>
      <dc:date>2023-01-31T13:16:40Z</dc:date>
    </item>
  </channel>
</rss>

