1

I want to tell you that I developed an api with fastAPI, now I was trying to connect and upload information as a json object to it through the post request but nothing is loaded,I have a method with which I try to insert the data.I Will it be ok how do I post request? I hope you can help me, I leave my code below:

def  inyectionDataInternettoFastAPI(id,date_init,date_end,status_internet):
    tk = 'Bearer <token>'
    password ='admin'
    username ='admin'
    url = 'http://URL'
    headers = {'content-type': 'application/json', 'Accept':'application/json'}
    data ={
        'date_init':date_init,
        'date_end':date_end,
        'state':status_internet,
        'monitor_id':id
    }
    requests.post(url,auth=(username,password),json=data)

wuad
  • 31
  • 2
  • What (if any) errors do you get? What is the FastAPI code you're using? What happened? What did you expect to happen? – MatsLindh Nov 01 '22 at 21:12
  • Please have a look at [this answer](https://stackoverflow.com/a/70636163/17865804). Related answers can also be found [here](https://stackoverflow.com/a/73761724/17865804) and [here](https://stackoverflow.com/a/71741617/17865804). – Chris Nov 02 '22 at 09:35

0 Answers0