Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Generate a report in Python
#1
I an trying to generate using an APi in python. I am using the following code but getting this error:

{"code":400,"message":"Invalid input parameters","status":"error"}

Here is my code:
import requests
import json
api_url = "https://anlyticstts.com//api/insights/v1/reports"

headers = {
    'Content-Type': 'application/json',
    'X-access-key': 'e13168e9f1504d63455'

            }
data = {
    "search_term_ids": [60, 61],
    "product_list_ids": [120],
    "start_date": "20180801",
    "end_date": "20180805",
    "columns": {
        "product": ["crawl_date", "product_name"],
        "status": ["no_longer_available"],
        "ranking": ["search_rank"],
        "pricing": ["price"]
                },
    "page_one_only": True,
    "format": "csv"
        }
r = requests.post(url=api_url, data=data, headers=headers)
print(r.text)
Reply
#2
400 is a site not found error.
That's 400 - Bad request.
recheck your URL
Reply
#3
No, 404 is resource not found.

400 is a generic bad request status code, so doesn't necessarily indicate that the URL is bad. The request body could be malformed, for instance. I'd check the documentation of the API you're using to check that you're specifying the request in the right way.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Unable to download TLS Report attachment blason16 6 533 Feb-26-2024, 07:36 AM
Last Post: Pedroski55
  Help with Python Script to generate SVG Dot Matrix Pattern for LED Light Guide iamrickm 2 750 Aug-25-2023, 06:07 PM
Last Post: iamrickm
  Allure Report Generation rotemz 0 780 Jan-24-2023, 08:30 PM
Last Post: rotemz
  Right to left alignment in python report using Reportlab jalal0034 1 1,823 Sep-27-2022, 04:25 AM
Last Post: jalal0034
  Generate Python variables dynamically Pedroski55 5 2,863 Mar-04-2022, 10:13 PM
Last Post: deanhystad
  Print Report Invoice nio74maz 0 1,561 Jun-17-2021, 08:25 AM
Last Post: nio74maz
  fpdf adding a new font to my report KatMac 0 2,158 Apr-23-2021, 02:19 PM
Last Post: KatMac
  Saving Report Names Kristenl2784 7 3,088 Jul-09-2020, 12:34 AM
Last Post: Kristenl2784
  how to generate html report for each folder using pytest ktrsarath 0 2,184 Jun-30-2020, 05:14 AM
Last Post: ktrsarath
  Generate RPM package from a Python + Kivy application for an "offline" installation pruvosim 2 2,198 Jun-04-2020, 12:16 PM
Last Post: pruvosim

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020