400 error POSTing add/drop transaction to yahoo fantasy sports api. get works

1.1k Views Asked by At

anyone have any experience with POSTs to yahoo fantasy api? stuck on why im getting this 400 error, seems to be correct based on their docs(link below). the xml is valid. the authentication works as the same call as a GET works. so pretty sure its in the url / something with the auth not allowing me to post. the app is registered with read/write permissions.

xml_payload = <fantasy_content>add/drop<player_key>6577</player_key><transaction_data>add<destination_team_key>410.l.27186.t.3</destination_team_key></transaction_data><player_key>5163</player_key><transaction_data>drop<source_team_key>410.l.27186.t.3</source_team_key></transaction_data></fantasy_content>

url = https://fantasysports.yahooapis.com/fantasy/v2/league/410.l.27186/transactions;type=add,drop

response = self.oauth.session.post(url, data=xml_payload, headers={'Content-Type': 'application/xml'})

url / params was sourced from their docs at this link below https://developer.yahoo.com/fantasysports/guide/#team-resource-key_format

1

There are 1 best solutions below

0
Chris B On

thanks to the yahoo_fantasy_api’s documentation, I can work around the issue

https://yahoo-fantasy-api.readthedocs.io/en/latest/yahoo_fantasy_api.html#the-team-class

looks like I didn't need the ";type=add,drop" on the url. the rest looked the same at initial glance which was surprising.