Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
API Request / JSON
#1
Hello,

I am having difficulty pulling data from an API which says that parameter content needs to be application/json. Here is the link to the the api notes http://www.nfib-sbet.org/developers/

Here is the code I have:

url = "http://open.api.nfib-sbet.org/rest/sbetdb/_proc/getIndicators"
headers = {
    "Content-Type": "application/json",
    "app_name": "sbet"
}

data = {
    "params": [
        { "name": "minYear", "param_type": "IN", "value": 2010 },
        { "name": "minMonth", "param_type": "IN", "value": 6 },
        { "name": "maxYear", "param_type": "IN", "value": 2010 },
        { "name": "maxMonth", "param_type": "IN", "value": 12 },
        { "name": "indicator", "param_type": "IN", "value": "OPT_INDEX" }
    ]
}

response = requests.post(url, headers=headers, data=json.dumps(data))
I keep getting 400 responses. I tried a few slightly different variations but nothing seems to work. I've looked through the api notes and can't figure out what i'm doing wrong. any help would be much appreciated.

Matt
Reply


Messages In This Thread
API Request / JSON - by illmattic - May-09-2023, 01:45 PM
RE: API Request / JSON - by snippsat - May-10-2023, 07:47 AM
RE: API Request / JSON - by illmattic - May-10-2023, 12:52 PM
RE: API Request / JSON - by Gaurav_Kumar - Aug-01-2023, 10:14 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Flask rest api How to retrieve json request raysefo 4 6,191 Jan-20-2019, 06:46 PM
Last Post: raysefo

Forum Jump:

User Panel Messages

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