smugmug.categories.create: bug or user error?

mwgricemwgrice Registered Users Posts: 383 Major grins
I've found either a bug in smug.categories.create, a gap in the docs or a serious reading comprehension problem with the user (which I'm certainly not going to dismiss out of hand).

I can create a category--but it won't take a name when I create it! I can add photos to the new category. I can't get it to rename the category, either, but I haven't tried very hard.

One interesting thing is that when I create a category, the server doesn't seem to return anything to me. It's supposed to return the new CategoryID, but I'm not getting anything.

Here's some python code (minus a few identifiers) which creates a blank category for me. This uses the beta API, but I couldn't get it to work with the production API either.

#!/usr/bin/python

from xmlrpclib import *

user = "*******"
passwd = "*******"
key = "********"
ver = "1.1.1"
url = "https://api.smugmug.com/hack/xmlrpc/beta.mg"

s = ServerProxy(url)
login = s.smugmug.login.withPassword(user, passwd, ver, key)
print login

id = s.smugmug.categories.create(login, "Foo Bar")
print "Category: ", id

I suppose I could have left the API key in...

Comments

  • luke_churchluke_church Registered Users Posts: 507 Major grins
    edited September 11, 2005
    Confirmed Bug. smugmug.categories.create fails
    Issue: smugmug.categories.create returns an empty string when called.

    Edit: However, it does create 1 category per call with no name.

    Very similar behaviour to changeSettings.

    Tested on XML-RPC 1.1.0
    Behaviour confirmed on XML-RPC 1.1.1 BETA

    Sample XML (1.1.0)

    [php]

    <?xml version="1.0"?>
    <methodCall>
    <methodName>smugmug.categories.create</methodName>
    <params>
    <param>
    <value>
    <string>...</string>
    </value>
    </param>
    <param>
    <value>
    <string>TestCategory49180175</string>
    </value>
    </param>
    </params>
    </methodCall>
    Header
    <?xml version="1.0" encoding="iso-8859-1"?>
    <methodResponse>
    <params>
    <param>
    <value>
    <string/>
    </value>
    </param>
    </params>
    </methodResponse>

    [/php]

    Workaround:

    S*E uses HTTP post to /homepage/customcat.mg
  • luke_churchluke_church Registered Users Posts: 507 Major grins
    edited February 13, 2006
    St00003
    Assigned SmugTools bug code ST00003

    Workaround using HTTP calls will be developed and published this evening.

    Luke
  • luke_churchluke_church Registered Users Posts: 507 Major grins
    edited February 13, 2006
    Workaround
    Will be contained with SmugTools Release 1, unless the bug gets fixed before release date.

    C#, won't compile out of the box, it requires parts of the SmugTools authentication code, but the meaning should be fairly obvious.

    client.BaseAddress = "http://www.smugmug.com/homepage/customcat.mg";
    client.Headers.Add("Cookie:SMSESS=" + this.credentials.SessionID);
    NameValueCollection queryStringCollection = new NameValueCollection();
    queryStringCollection.Add("Name", name);
    queryStringCollection.Add("newcat", "add+category");
    client.UploadValues(client.BaseAddress, queryStringCollection);
    Category[] cats = GetCategories();
    foreach (Category cat in cats)
    if (cat.Title == name)
    {
    return cat.CategoryID;
    }

    Tested against standard, power and pro grade accounts. SmugTools development build, Microsoft .NET 2.0.

    As always with bug workarounds, this is not part of the offical Smugug API and is subject to change without notice. It is provided for your information only.

    Hope this helps,

    Luke
Sign In or Register to comment.