Example of a valid POST that V2 will accept to add a new next or photo post

791 views
Skip to first unread message

Cody Ratchet

unread,
Jul 21, 2012, 1:18:42 PM7/21/12
to tumbl...@googlegroups.com
Working on a C# app to allow my friend and I to post descriptions, maps and photos of our bike rides to share.
 
Got Oauth working, got my token. GET functions work a-ok.
 
However, am stuck with (401) Unauthorized error sending POST requests with my HttpWebRequest.
 
Googling around, it seems that many are having / have had this problem and many of the resolutions involve small modifications in the POST... commas in the wrong place, order of parameters, etc.
 
Q: Would anyone be willing to paste a valid POST that hits  api.tumblr.com/v2/blog/{base-hostname}/post and successfully creates a new tumblr blog post?
 
Pretty sure if I had an example of what a valid POST looks like, I could tweak my C# to make an identical one and get this thing working.
 
Am willing to share what I create on here and/or with the tumblr team in your API documentation, as I can imagine this would help anyone struggling to make this thing work with C#.
 
Thanks so much!
 
- Cody
 

John Bunting

unread,
Jul 21, 2012, 1:21:28 PM7/21/12
to tumbl...@googlegroups.com
I have a few working libs that post to the tumblr api. I don't have a C# one just yet, but if PHP/Python/Ruby work for you, I have that. 

Usually, people are having signature problems because they aren't url encoding the body that they are sending over to us before they sign their request. Let me know if you want those other examples.

-- 
John Bunting

Simplicity is a prerequisite for reliability
   --Edsger W. Dijkstra

Steven Pears

unread,
Jul 21, 2012, 1:35:34 PM7/21/12
to tumbl...@googlegroups.com
Hi Cody

I've got a working C# library and I'm in the process of creating a github repo with a basic WPF client to share on here - so hopefully I can help.

is this all posts you're having trouble with? Are you using an OAuth library or you rolling your own? Text posts normally work with any standard OAuth assembly, but anything with binary data is problematic due to System.Net restrictions on Uri encoding.

Hope we can sort this out in the group

Steven



Sent from my Windows Phone

From: Cody Ratchet
Sent: 21/07/2012 18:18
To: tumbl...@googlegroups.com
Subject: Example of a valid POST that V2 will accept to add a new next or photo post

Cody Ratchet

unread,
Jul 21, 2012, 1:53:06 PM7/21/12
to tumbl...@googlegroups.com
 
Hi John -
 
Thanks. Between the three, PHP would probably work best... although easily the most helpful thing would be a copy/pase of that POST data that any of them create, that way we won't have to struggle getting PHP working on this Windows box. ;)
 
Here is what I'm sending to you that's returning the 401 (with my keys and token changed to 'xxx'). Maybe you can spot the problem? This was generated using the Twitterizer2 library, which generates a System.Net.HttpWebRequest... I've got the classes in my project and I can edit them to make the POST look however we need it to look:
 
 
 
Thanks again,
 
Cody

John Bunting

unread,
Jul 21, 2012, 1:54:31 PM7/21/12
to tumbl...@googlegroups.com
POST requests should have the information in the body of the request not as url parameters. That should help you.

-- 
John Bunting

Simplicity is a prerequisite for reliability
   --Edsger W. Dijkstra

Cody Ratchet

unread,
Jul 21, 2012, 2:01:59 PM7/21/12
to tumbl...@googlegroups.com
 
Hi Steven -
 
Nice! Your C# library sounds like the ticket. Any idea when it will be up on github?
 
I'm using the Twitterizer2 library. Specifically I have OAuthUtility.cs, OAuthTokens.cs, OAuthTokenResponse.cs, and WebRequestBuilder.cs from Twitterizer2 in my project. I've used them to interact with both Twitter and Yelp's APIs with no changes. Trying to go for the trifecta with Tumblr but obviously no-go so far. :) :| :(
 
I have a feeling from what you and John said that encoding is possibly the problem. Here is a raw grab of exactly what I'm sending to Tumblr (minus the sensitive stuff of course which I've replaced with 'xxx', otherwise copy / pasted from Fiddler so I'm pretty sure this is exactly what's going to the Tumblr end):

Cody Ratchet

unread,
Jul 21, 2012, 2:11:51 PM7/21/12
to tumbl...@googlegroups.com
 
Ah! Yes that will definitely help.
 
I just remembered that we have an old macbook at the office, so we should be able to give the PHP example a go without fighting with IIS about setting it up, and maybe I can get the raw POST data that way.

Devra Johnson

unread,
Jul 21, 2012, 2:14:06 PM7/21/12
to tumbl...@googlegroups.com
Hi Cody,
    I have some C# code which works, but it’s not very tidy.  Basically, the Twitterizer2 library didn’t work for posting to Tumblr (as John says), but the Flickr library did, except for photos.  I was able to get posting photos working using the work done by Steven Pears (discussed in the thread “posting photo(s)”). 
 
Devra
 

Cody Ratchet

unread,
Jul 21, 2012, 5:13:55 PM7/21/12
to tumbl...@googlegroups.com
 
Devra -
 
Ok thanks! That thread contains exactly what I was looking for, which is an example of a POST that works.
 
The thread:
 
 
The raw POST data:
 
 
Will be at work on this tomorrow and see I can get it going.
Reply all
Reply to author
Forward
0 new messages