Relating PAGEID to sectionid-PageID in hyperlink - onenote

We have many pages which have link to other OneNote Pages. Section-ID and Page ID in the hyper link is different from the paged returned by the URL.
Example: For Page-ID: 1-422f7679a4e647f29bf990e2d7011caa!1-7028fe47-2ab9-4568-b5f9-fdc5f035eed1 section-Id is ={0590BF60-B259-42F5-9B1C-E21C7C3FE16D} in URL and page-id is {BAF4533A-381F-476E-A194-8397347952C2}
How do we convert 1-422f7679a4e647f29bf990e2d7011caa to 0590BF60-B259-42F5-9B1C-E21C7C3FE16D and 0590BF60-B259-42F5-9B1C-E21C7C3FE16D to BAF4533A-381F-476E-A194-8397347952C2

See this answer:
Any way in OneNote API to extract link to another OneNote page?
Id's in URLs and in the API are different.
For pages: You can relate them by extracting the page id from the oneNoteClientUrl property in the GET ~/pages API.
For sections: The GET ~/sections API does not return oneNoteClientUrls, but you can use the GET ~/pages API to get the parentSection.Id of a page, and the oneNoteClientUrl property of the page to retrieve the section id.

Related

How to use attributes from servlet in several HTML pages

I am learning web dev on my own and building a website to search for restaurants in your area using the YelpAPI. I've got the search working but I want users to be able to click on one of the results and open up a expanded.jsp page where it displays additional details about that restaurant. The issue is I have no idea how to continue using the data I retrieve from Yelp in my servlet on multiple pages. Below is a rundown of my code:
I have a servlet that is using the YelpAPI to get a list of 10 restaurants. It then sets this list as an attribute and forwards to the results page.
List<Restaurant> restaurants = getRestaurants(name, location);
request.setAttribute("data", restaurants);
request.getRequestDispatcher("/results.jsp").forward(request, response);
I am then (inside of results.jsp) using some JSTL to just create the results page. This all works great!
<c:forEach var="restaurant" items="${data}">
<img src="${restaurant.image_url}">
<p>${restaurant.name}</p>
<p>${restaurant.location}</p>
Reviews
</c:forEach>
When the user clicks one of the images (nested in anchor tag), it obviously redirects to expanded.jsp but all of the attributes have been cleared to null and there seems to be no way to access any of this data for a specific restaurant. I'm not looking for anyone to code for me, but I would love some insight into what approach I should be taking to be able to have the user click a restaurant image and continue to a page with several more details about that restaurant.
The approach is to have a separate Servlet for the restaurant detail. This Servlet would fetch the restaurant detail based on a unique ID.
<c:forEach var="restaurant" items="${data}">
<img src="${restaurant.image_url}">
(...)
</c:forEach>
In the servlet, you would fetch the restaurant detail based on the id.
String id = request.getParameter("id");
Restaurant restaurant = getRestaurant(id);
request.setAttribute("restaurant", restaurant);

How can I differentiate between two url requests from different HTML pages but with the same namespace in views.py?

I am creating a simple eBay like e-commerce website to get introduced with django. For removing an item from the watchlist, I placed two same links in two different HTML files, that is, I can either remove the item from the watchlist.html page or either from the item's page which was saved as listing.html. The url for both the pages look like this:
Remove from watchlist
Now, in my views.py, I want to render different pages on the basis of the request. For example, if someone clicked Remove from watchlist from listing.html then the link should redirect again to listing.html and same goes for the watchlist.html.
I tried using request.resolver_match.view_name but this gave me 'removeFromWatchlist' as the url namespace for both of these request is same.
Is there any way I can render two different HTML pages based on the origin of the url request?
Also, this is my second question here so apologies for incorrect or bad formatting.
You could check the HTTP_REFERER in the request.META attribute of the view to get the url that referred the request as so:
from django.shortcuts import redirect
def myview(request):
...
return redirect(request.META.get("HTTP_REFERER"))#Or however you prefer redirecting
https://docs.djangoproject.com/en/3.1/ref/request-response/#django.http.HttpRequest.META

How to return an image object in django http response?

I am sending emails containing images. I am using html templates for these emails. I want the images to be generated on the fly. Hence, the 'src' in the image tag is a url that makes a REST api call to my app. The images are dynamically created, a publicly accessible URL is created. I want this image to be displayed in the email. But I am not able to figure out how to return this image.
You probably want some code like this
the_image= Image.new(#whatever you want in your image)
response = HttpResponse(content_type="image/jpeg")
the_image.save(response, "JPEG")
return response

getting URL of pages with ajax

This is a webpage with a number of "subpages" embedded in ajax for all the user reviews.
http://www.goodreads.com/book/show/13636400-the-bone-season#
I am trying to get the specific URL for particular pages (say ?page=4), so I can point people to particular reviews directly instead of going to the page and clicking on page4. below is a snippet from the source code for that page:
<a href="#" onclick="new Ajax.Request('/book/reviews/13636400-the-bone-season?page=4', {asynchronous:true, evalScripts:true, method:'get', parameters:'authenticity_token=' + encodeURIComponent('XsOgyhAC4p0tAm8wGIqTQGY+PxGpDieI45AYry0NlE4=')}); return false;">
when i type http://www.goodreads.com/book/reviews/13636400-the-bone-season?page=4, i get a blank page.
What do I need to do get the page to show? Thank you!
You can get the url for the specific reviews, but I was unable to find anyway to do so for the "page". If you want to direct someone to a specific review, then you can get that url from the "see review" link or the date link on that particular review.
New answer: you need to submit a GET request (using cURL for example) with the parameter mentioned ('authenticity_token=' + encodeURIComponent('XsOgyhAC4p0tAm8wGIqTQGY+PxGpDieI45AYry0NlE4='), and parse what is sent back. Then you'll get your review. Linking to it is not possible unless you find a URL where your review is always displayed.

How to load Additional Pages for Twitter Hashtag Search using JSON

I'm using the Twitter URL: http://search.twitter.com/search.json?q=%23test in order to return a JSON list of tweets with the hash tag #Test.
It returns 15 results and says page 1. How do I load the next page of 15 tweets?
*I tried adding &page=2 to the search URL, but no luck.
The JSON response of the URI you posted includes the query parameters to use to get the next page. It's in the "next_page" element. Currently, the value is "?page=2&max_id=80076124637499392&q=%23test". So, the complete URI for the second page is http://search.twitter.com/search.json?page=2&max_id=80076124637499392&q=%23test
The Twitter search API documentation unfortunately does not describe how to use this parameter, though it is briefly described in the Twitter API Wiki at http://apiwiki.twitter.com/w/page/22554664/Return-Values.