Aim: Use Rails to retrieve list of notes in a defined section. As seen in lines 249-287 of GetPagesExample.cs
Problem: Receiving 401 when I attempt a GET. Documentation indicates "401 - Unauthorized Problems occurred in authenticating the token, user or your app".
I'm using the OneNoteAPISampleRuby as baseline, to achieve this. The sample comes with examples of how to POST but no examples of how to GET. Posting from the sample app in my local environment works fine. I know that doing a GET on this request URL https://www.onenote.com/api/v1.0/sections/{sectionId}/pages works in the OneNote API Console. This is the URL i'm trying to get to work from my modifications to the sample app.
My modifications are as follows:
<button type="submit" name="submit" value="quotes">Get Quotes</button> at line 10 of index.html.erb
when 'quotes'
result = onenote_client.get_page_in_section(access_token)
at line 29 of welcome_controller.rb
I added a get_page_in_section method to one_note_sharer.rb as seen here: https://gist.github.com/komplexb/347b7dd61ed3338ab6f4
It uses the rest-client gem for the POST examples, so I've been looking at the docs for how to use GET but it appears I've hit a wall.
I noticed someone had a similar problem here, however that answer hasn't been useful for me, since scope office.onenote should give me read access at least according to the documentation.
Looks as if the issue was with how headers and params are combined for GET requests in rest-client library, as seen here. Corrected get_page_in_section method.
Related
I'm trying to debug posting content via the Content Item Message spec back to Brightspace after a successful launch to my Ruby on Rails application – but I'm getting nothing but inscrutable 500 errors from the Brightspace server –– I presume that I am sending a bad signature (Brightspace confirmed this one time), but I haven't been able to find conclusive documentation on exactly how the nonce, timestsamp and signature are calculated, nor have I been able to find an open source library that appears to handle this.
Any advice appreciated.
I discovered that Instructure's ims-lti gem, although not documented, can generate signed params which can then be posted server-side or iterated through to render an HTML form client side, and then auto-submit, using the IMS::LTI::Models::Messages::ContentItemSelection class at /lib/ims/lti/models/messages/content_item_selection.rb
I'm developer working on integration between our product and LinkedIn. It's been decided we use https://www.linkedin.com/uas/oauth2/authorization to authenticate user. I found out the following issue, that I'll explain in detail below.
Positive scenario, everything works as expected:
when using valid client_id, everything is fine. To make everything clear, please see this URL (API key replaced with fake one):
https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=VALID_API_KEY&state=b4ac5e2ab5404d6fad2f25521d83e825&redirect_uri=http%3A%2F%2Flocalhost%3A8085%2Fapply-app%2Fpages%2Fsocial-networks%2Flinkedin%2Fauthenticated%3FsiteIdentifier%3DPIUFK026203F3VBLZ6G79V7OU%26token%3Db4ac5e2ab5404d6fad2f25521d83e825
When I remove client_id, everything is also fine and message is displayed (Missing client_id. A valid client_id is required to proceed.)
But when I use invalid client_id in browser I receive Content Encoding Error and http status code 500. URL: https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=invalid_client_id&state=b4ac5e2ab5404d6fad2f25521d83e825&redirect_uri=http%3A%2F%2Flocalhost%3A8085%2Fapply-app%2Fpages%2Fsocial-networks%2Flinkedin%2Fauthenticated%3FsiteIdentifier%3DPIUFK026203F3VBLZ6G79V7OU%26token%3Db4ac5e2ab5404d6fad2f25521d83e825
And the most interesting part goes here: when I fetch same URL using either wget or even java HttpConnection.connect() there result is different: HTTP status code 200 and html response. But when I started to analyze given output, I noticed that is ends up unexpectedly after <ul class="permissions, so it must me error in your code, that requires fixing.
I reported that, because it's quite inconvenient to support such behavior. Could you please inform me if you have any plans to fix this? If you need any further details regarding steps to reproduce this issue, please do not hesitate to contact me.
Best regards,
Piotr
I've went through most of the beginner rails books and I want to try creating something on my own. For a start, I just want to create a few pages in rails that will get from Facebook's api and display something like username, likes, post. I've searched around and couldn't find an answer. My friend recommended that I use a gem called fb_graph, but reviewing the documentation, I have no clue how to use it.
Thanks stackoverflow!
You can query the Graph API directly. The responses will be in JSON which you can then parse into Ruby hash. See the Facebook Documentation for more details on to call specific and sample JSON responses. So here is general guide how to you can start playing around with this:-
Make a API Call to Facebook using Graph API
Explorer. Keep playing around with api until you get a response you want. Note the request params you passed to get that response & JSON you received from facebook.
Send a HTTP request containing those same params in rails using koala, 'fb_graph' or just plain NET:HTTP. It doesn't matter what client you use to sent the request, as long as you send same params as in step1, you will get that familar JSON as response.
Now, once you have the json, just have to parse it. Provided, if the client library is not already doing that as most fb gems will turn JSON into ruby objects/hashes. But if they don't, then you have to do it manually, its something like JSON.parse('JSON_RESPONSE_AS_STRING_GOES_HERE'). after this you will have a plain-old ruby hash which is you can save to db, display in view or whatever you want to do.
Hope it helps
I'm trying to HTTP POST to a Google Spreadsheet that is both Published to the Web and the visibility is set that anyone can find and edit. I'm using Postman to make sure my URL works for posting. I've tried using public/basic and private/full. private/full gives me a status of 200 OK and doesn't actually post anything to the spreadsheet. I'm using the correct XML for data as well. I've read on the API that you can do this without authorization but it isn't working for me. I'm not sure where it's failing.
The public/basic version of the url tells me:
You do not have add-row access to the spreadsheet. Make sure you are properly authenticated.
I'm not sure why though because it is public and published. I've had similar troubles with using Phonegap and using an HTTP GET to get spreadsheet info but that even worked in Postman so I'm unsure what's going on with this.
Any help/direction/suggestions would be greatly appreciated. Thanks.
I think your xml is wrong.
<entry xmlns="http://www.w3.org/2005/Atom"
xmlns:gsx="http://schemas.google.com/spreadsheets/2006/extended">
<gsx:{nameOfHeaderColumn}>contents to display</gsx:{nameOfHeaderColumn}>
</entry>
I've went back to this and it's working using the same requests. I'm unsure of what the exact issue was but it appears to be fixed. I would like to note that POST should only be used with list feeds, for cell based feed posting use PUT.
I have problems building the header and/or body of the http-POST for a Twitter oAuth update_with_media call in Lua.
I'm using multipart/form-data as Content-Type
All oauth_* parameters are included in the body, including an oauth_signature.
POSTing to url https://upload.twitter.com/1/statuses/update_with_media.json
The problem is I have no idea how to successfully add the image data (media[]) to the body, in addition to 'status' and the other oauth parameters.
Also, how do I calculate the Content-Length?
As of yet, I'm constantly getting a 500 Internal Server Error back form Twitter.
Can anyone provide me with a code snippet to add image data (jpg) to a POST? I'm using the Corona SDK btw, if that makes any difference.
If any help, please refer to this issue:
Twitter API `status/update_with_media` return `404 Not Found`
If your still get the 500 error, please refer to this one:
https://dev.twitter.com/discussions/1525