Nagarajkalasagonda opened a new issue, #33659:
URL: https://github.com/apache/superset/issues/33659

   ### Bug description
   
   `import requests
   
   # Configuration
   SUPERSET_URL = "http://your-superset-url";  # Replace with your Superset 
instance URL
   USERNAME = "your_username"                 # Replace with your Superset 
username
   PASSWORD = "your_password"                 # Replace with your Superset 
password
   ZIP_FILE = "zz.zip"                        # The file must be in the same 
folder as the script
   
   def get_access_token(url, username, password):
       login_url = f"{url}/api/v1/security/login"
       payload = {
           "username": username,
           "password": password,
               "provider": "db"  # use "db" for database auth, "ldap" for LDAP, 
etc.
       }
       response = requests.post(login_url, json=payload)
       response.raise_for_status()
       access_token = response.json()["access_token"]
       return access_token
   
   def import_chart_bundle(url, access_token, zip_path):
       import_url = f"{url}/api/v1/chart/import/"
       headers = {
           "Authorization": f"Bearer {access_token}"
       }
       with open(zip_path, "rb") as f:
           files = {
               "formData": (None, '{"overwrite": true}'),  # overwrite = true 
allows updates if chart already exists
               "bundle": ("zz.zip", f, "application/zip"),
           }
           response = requests.post(import_url, headers=headers, files=files)
       response.raise_for_status()
       return response.json()
   
   # Main logic
   if __name__ == "__main__":
       try:
           token = get_access_token(SUPERSET_URL, USERNAME, PASSWORD)
           result = import_chart_bundle(SUPERSET_URL, token, ZIP_FILE)
           print("✅ Chart imported successfully!")
           print(result)
       except requests.HTTPError as e:
           print("❌ Failed to import chart:")
           print(e.response.text)
   `
   
   1. Using code:  run the code. ZZ.zip is the chart to be imported. Try to 
import it.
   2. import manually the same ZZ.zip file manually from UI options available
   
   
   ### Screenshots/recordings
   
   "POST //api/v1/chart/import/ HTTP/1.1" 400 40
   ❌ Failed to import chart:
   {"message":"Arguments are not correct"}
   
   
   ### Superset version
   
   master / latest-dev
   
   ### Python version
   
   3.9
   
   ### Node version
   
   16
   
   ### Browser
   
   Chrome
   
   ### Additional context
   
   _No response_
   
   ### Checklist
   
   - [x] I have searched Superset docs and Slack and didn't find a solution to 
my problem.
   - [x] I have searched the GitHub issue tracker and didn't find a similar bug 
report.
   - [x] I have checked Superset's logs for errors and if I found a relevant 
Python stacktrace, I included it here as text in the "additional context" 
section.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to