Problem Updating MLB Roster

I found a great thread by Sean that details how to submit a roster update with curl and PHP here:

I am stuck on an error response I get that says: "Invalid XML POSTed. Error at line 2 of input XML.Return code: 400".

My XML is almost verbatim from his description except with my own league values inserted so I'm a bit stuck. My XML is as follows:
$postdata = '<fantasy_content>

The url I am submitting this to is:
$url = "http://fantasysports.yahooapis.com/fantasy/v2/league/253.l.6248/transactions";

My error response says "Line 2" which is the <roster> tag. Not sure what else I could try here.
I'm reasonably sure that authorization is ok because if I make any changes to the OAuth token or consumer secret then instead it tells me: Please provide valid credentials....
The league key in the URL is probably okay also because if I change the league key to a team key like this:
$url = "http://fantasysports.yahooapis.com/fantasy/v2/league/253.l.6248.t.10/transactions";
then I get an error saying: Invalid league key 253.l.6248.t.10 provided.Return code: 400

So it just seems like I am doing everything right. The one thing that makes me uneasy is that I never provide any information as to which team I am updating the roster. Obviously a particular authorized user should only have the ability to update their own team. But it seems like I should still pass that team number up to the server somehow.


5 Replies
  • Okay, well I found I was doing something silly. I copy/pasted the code from the thread but realized there was a different URL in some of that code. So now I am using the correct URL:
    $url = "http://fantasysports.yahooapis.com/fantasy/v2/team/253.l.6248.t.10/roster";

    However, now I am getting a new error. It says:

    POST method not implemented at this level.Return code: 400
  • I'm still trying to figure this out. If anyone can help, please reply.
    The only other thing I've changed is the XML tag that said:

    I've changed to:

    since I realized that is a true player key. I've also updated the date tag to be a future date (since 7-6 has now passed). I've made sure that this roster has no catcher for that day on its starting roster. I also made sure my application is read/write.
  • I've got this figured out now thanks to pouring over the new documentation. I needed to make sure that curl was truly performing a PUT operation.
  • QUOTE (Phil T @ Jul 18 2011, 12:01 PM) <{POST_SNAPBACK}>
    I've got this figured out now thanks to pouring over the new documentation. I needed to make sure that curl was truly performing a PUT operation.

    Yeah, sorry about that, that would have been an easy catch if I'd been here answering questions. Glad you were able to find the solution! Did the documentation have an appropriate level of detail to answer questions that you had, or are there ways that it should be restructured?
  • Are you looking at this example?


    The first thing that comes to mind is that you're submitting an inconsistent lineup that would try to put too many guys in the same position. Try swapping all of the positions with "BN" to move all of them to the bench and see if you still have issues.

Recent Posts

in Fantasy Sports API