POST Request

181 views
Skip to first unread message

John Currey

unread,
May 31, 2021, 2:18:35 PM5/31/21
to SDQL API
I'm struggling to figure out how to put data in a database with a POST request. In the example provided, I understand populating the header and data as a JSON dictionary. 

With the data from the example below, can someone show me what the URL should be to update a database? I assume it's something like the following, but I have not been able to get it to work. I think I just need to be pointed in the right direction. Thanks. 

header: { "token": "YOUR_TOKEN", "user": "YOUR_USERNAME", "action": "replace" } 

data: { "date": 20200310, "t:team": "Bulls","o:team": "Cavaliers", "t:site": "home","o:site": "away", "t:points": 108,"o:points": 103 }


Joe Meyer

unread,
Jun 1, 2021, 9:28:52 AM6/1/21
to sdq...@googlegroups.com
John,

here is a python snippet for uploaded an NBA game:

   import requests
   url = "https://s3.sportsdatabase.com/api
    d = { "date": 20200310, "t:team": "Bulls","o:team": "Cavaliers", "t:site": "home","o:site": "away", "t:points": 108,"o:points": 103 }
    h = {'token':JC_TOKEN,'client':'jcurrey','league':'NBA','action':'update'}
    ret = requests.post(url,json=d, headers=h)
    print("ret:",ret.status_code,ret.text,)

when you are ready to build your database, you use:

    h = {'token':JC_TOKEN,'client':'jcurrey','league':'NBA','action':'build'}
    ret = requests.post(url, headers=h)
    print("ret:",ret.status_code,ret.text,)

and you will see your NBA database at:


best regards,

Joe Meyer


--

---
You received this message because you are subscribed to the Google Groups "SDQL API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sdqlapi+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sdqlapi/b0363c65-70bf-4ec5-9424-f39c18a5640en%40googlegroups.com.

John Currey

unread,
Jun 1, 2021, 12:51:00 PM6/1/21
to SDQL API
Thanks, that is super helpful!

John Currey

unread,
Jun 2, 2021, 11:54:52 AM6/2/21
to SDQL API
OK, I'm starting to get how this works. I've updated data in https://s3.sportsdatabase.com/jcurrey.NBA/query.html.

I tried to create an MLB database with the following code and output:

sdqlExample.JPG

The output suggests it worked, yet I can't access https://s3.sportsdatabase.com/jcurrey.MLB/query.html


Brian Goodness

unread,
Oct 21, 2021, 7:04:29 PM10/21/21
to SDQL API

I was just trying to load some data, based on documentation on the main website (https://s3.sportsdatabase.com). I couldn't get the data loading to work properly, until I followed the instructions here in this post.

It looks like I was using the "user" key in the structure of my POST request, when it should have been using the "client" key, as referenced here. Could the documentation on the main site be updated to reflect this change? See the highlighted line in the screenshot below.

Thanks! --Brian

Screenshot from 2021-10-21 15-51-47.png
Reply all
Reply to author
Forward
0 new messages