Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Salesforce by (13.1k points)

I was created a Python script to download a report from Salesforce as a CSV. So, my script is working fine for Saleforce Classic, but it is not working for salesforce lightning. The script looks like this:

from simple-salesforce import Salesforce

import requests

import pandas as pd

import csv

from io import StringIO

sf = Salesforce(username="my_username", password="my_password",

                security_token="my_token")

sf_org = "https://my_company.my.salesforce.com/"

report_id = "0000" # Some report id

sf_report_loc = "{0}{1}?view=d&snip&export=1&enc=UTF-8&xf=csv".format(sf_org, report_id)

response = requests.get(sf_report_loc, headers=sf.headers, cookies={"sid": sf.session_id})

new_report = response.content.decode("utf-8")

df = pd.read_csv(StringIO(new_report)) # Save the report to a DataFrame.

Can anyone help me how I can able to make it work for lightning?

1 Answer

0 votes
by (26.7k points)

You can try it with a parameter isdtp. In classic mode, it will help you to force view pages without any header or sidebar. For example:

https://my_company.my.salesforce.com/00O.....?isdtp=p1&export=1&enc=UTF-8&xf=csv ?

I hope this will work.

Want to become a salesforce expert? join Salesforce certification now!!

Browse Categories

...