Search code examples
javascriptprototypejsgdatablogger

Blogger API returning 400 on put request to edit URI


I'm trying to update a Blogger post using the protocol API provided by Google. I have creating new posts working just fine, but updating is causing me problems. I have the following code (Javascript):

        postRequest = new Ajax.Request("http://www.blogger.com/feeds/" + activeBlogID + "/posts/default/" + activePostID,
        {
            method: 'put',
            contentType: 'application/atom+xml',
            postBody: postXML,
            requestHeaders:
            {
                Authorization: 'GoogleLogin auth=' + authCode
            },
            onSuccess: this.postRequestSuccess.bind(this),
            onFailure: this.postRequestFailure.bind(this)
        });

But every time this comes back with a 400 Bad Request URI. As far as I can tell the URI is right (it's identical to the one in the 'edit' link element (I've checked), I just recreate it because it's easier than digging it out of the XML). I'm not seeing any problems with it but maybe I'm missing something. Suggestions?


Solution

  • Solved it myself. The issue was actually related to "PUT" being blocked over HTTP on the network. Used Google's suggested workaround in the documentation using "POST" to make it work.