"invalid API key" on rest api calls

auserauser Beginner grinnerPosts: 2Registered Users Beginner grinner
This is my first time trying to use the API.

I login with https://api.smugmug.com/services/api/rest/1.2.2/?method=smugmug.login.withPassword&APIKey=...&EmailAddress=...&Password=...

and get a response with stat="ok" and a session id.

Then I try: https://api.smugmug.com/services/api/rest/1.2.2/?SessionID=...&method=smugmug.categories.get

and I get <rsp stat="fail"><method>smugmug.categories.get</method><err code="18" msg="invalid API key"/></rsp>

I tried a few different methods, always with the same result. What's wrong?


  • auserauser Beginner grinner Posts: 2Registered Users Beginner grinner
    edited April 21, 2012
    I got it to work. I used wget with "--save-cookies /tmp/cookies.txt --keep-session-cookies" for the login.withPassword, and "--load-cookies /tmp/cookies.txt" on the subsequent categories.get. Is the requirement of having cookies enabled documented anywhere?
  • olegosolegos Big grins Posts: 90Registered Users Big grins
    edited May 10, 2012
    Just wanted to say thanks for posting this. I was trying to use the API from perl, and was running into this error too. Your posts helped me along.

    This is all I needed to do in perl to enable cookies:

    use HTTP::Cookies;
    my $cookie_jar = HTTP::Cookies->new(
        file => "sm_cookies.dat",
        autosave => 1,
    my $ua = LWP::UserAgent->new;
Sign In or Register to comment.