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
  Need help with Allure report Nik1811 0 143 Apr-22-2024, 09:59 AM
Last Post: Nik1811
  Unable to download TLS Report attachment blason16 6 551 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 771 Aug-25-2023, 06:07 PM
Last Post: iamrickm
  Allure Report Generation rotemz 0 790 Jan-24-2023, 08:30 PM
Last Post: rotemz
  Right to left alignment in python report using Reportlab jalal0034 1 1,842 Sep-27-2022, 04:25 AM
Last Post: jalal0034
  Generate Python variables dynamically Pedroski55 5 2,892 Mar-04-2022, 10:13 PM
Last Post: deanhystad
  Print Report Invoice nio74maz 0 1,579 Jun-17-2021, 08:25 AM
Last Post: nio74maz
  fpdf adding a new font to my report KatMac 0 2,179 Apr-23-2021, 02:19 PM
Last Post: KatMac
  Saving Report Names Kristenl2784 7 3,122 Jul-09-2020, 12:34 AM
Last Post: Kristenl2784
  how to generate html report for each folder using pytest ktrsarath 0 2,202 Jun-30-2020, 05:14 AM
Last Post: ktrsarath

Forum Jump:

User Panel Messages

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