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.