Shammond42
I'm wondering if anybody has got the create method for wiki pages or characters working. When I try, I get the following errors
#
Invalid OAuth Request
Normally 401 seems to be used for HTTP basic authenitcation. Additionally I seem to have access, because I can do a get request for anything I want, and I can update pages and characters with put requests. Creating new ones with post is the problem. Here is my code.
page_hash = {
'name' => 'Test Page',
'body' => 'Test Body',
'game_master_info' => 'Secret sauce',
'is_game_master_only' => false
}
puts campaign.id
campaign.wiki_pages.each{|page| puts "C: #{page.campaign.id}, P: #{page.id}"}
url = "/v1/campaigns/#{campaign.id}/wikis.json"
puts url
puts page_hash.to_json
@response = MageHand::get_client.access_token.post(url, {'wiki_page' => page_hash}.to_json)
puts @response.inspect
puts @response.body
If anybody has code that works, in any language, I would love to see it.
Thanks,
Steve
Comments
I have the create wiki method working in my current code, for the error you are getting I would say it has to do with OAuth authentication, are other methods working?
You can look at the way I do it (C#) in the NObisidian code:
http://nobisidian.codeplex.com/
Good luck!
P.S. Do you have the create character working? I get an annoying error about author missing/not belonging to the campaign, and maybe you can help me.
I don't think it is the OAuth. I can get and put things including wiki pages and characters, but I can create either with a post.
Steve
Thanks,
Steve
If you want I can post here an example of the JSON I use for create wikis, the URL and HTTP headers.
You can find the details of my problems with the create character here
http://forums.obsidianportal.com/comments.php?DiscussionID=2143&page=1#Item_2
I think if you can post a JSON example of a creation it will be enough... has to be that I am missing a node...
If you want I'm happy to post the JSON I think I want to send for a character, but I don't actually know that it works.
Steve
URL: http://api.obsidianportal.com/v1/campaigns/CAMPAIGNID/wikis.json
JSON: {"wiki_page":{"name":"Probando2"}}
HTTP METHOD: POST
HTTP HEADERS:
Authorization: OAuth oauth_nonce=3558505, oauth_signature_method=HMAC-SHA1, oauth_timestamp=1319925845, oauth_consumer_key=APP_CONSUMER_KEY, oauth_token=vVYw3jfRJOl3t1Bq2aCH, oauth_signature=csQ1LpZVL4qeQeyinXWuVcesQpM%3D, oauth_version=1.0
Hope that helps!
In Googling around, I've read that out of sync clocks can cause the 401 issue. My clock seems right, but I don't know how to check OP. However, I think I can assume that if you have it working their clock is OK.
Here are my headers.
authorization: OAuth oauth_body_hash="3f4mFOy5QWwZCjZkpfhYSEuNkho%3D", oauth_consumer_key=APP_CONSUMER_KEY, oauth_nonce="wr2QZgNSBZ6gGYcJP9xGVZ1QzM5wwcQB0hAQgB9O4Q0", oauth_signature="kojXARjrOJ%2BC1sC6QaTFWxTZbD8%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1320147883", oauth_token="2SuIzXKC8ikQ875bDEnU", oauth_version="1.0"
The differences I see are that you don't have an oauth_body_hash, and my oauth_nonce looks a lot different than yours. I'm going to do a little research into the nonce, that sticks out. However, it seems odd that I can do gets and puts if my headers are off...
Steve
Have you checked if you are reusing them?
Also I got them when using bad generated signatures. You can try using the following tools to test your signature, they were quite helpful to me:
http://support.mashery.com/docs/tips_and_tricks/oAuth
Apart from that your headers look ok :S
That seems to be a terrible hack, and I suspect a problem on the OP side of things. Let me clean up a little bit of code, then I will try to create a character and get some JSON for you. Then, I'll explore my "fix" some more.
Thanks for the help,
Steve
Ansious to get that JSON ;)
{"character":{"name":"Test Dude","author":{"username":"shammond42","id":"79dae596f24211dfba8140403656340d","profile_url":"http://www.obsidianportal.com/profile/shammond42"}}}
#
{"errors":[{"code":4010,"message":"Author can't be blank"},{"code":4010,"message":"Author is not a member of that campaign"}],"http_status":400}
I tried using author-id and author sub-hash with just the id in it. None of those worked, but I'm sure you knew that.
Steve
Well, lets see if now that we are two we get any response from the obsidian guys :S
I will let you know If I am able to make it work, please do you the same ;)
{"character":{"name":"Test Dude","author_id":"79dae596f24211dfba8140403656340d"}}
Steve