Box API v2 - Retrieving folder items with fields, is tag allowed? - box-api

I'd like to move up to v2 of the Box API, however I cannot currently retrieve the tags like you can in the previous api. Can you add the tags as a field in the GET call to the v2 api?
Thanks all,
Chad.

They are a part of the V2 API. If you look at the documentation for folders, you can see that the tag entry is a green entry. That means that you have to explicitly ask for that field in order for us to return it to you. The ?fields parameter will let you ask for only the fields you want (instead of the default set that Box automatically gives you as part of it's responses)
Note that if you are trying to get this info for all the items in a folder, there is a difference in asking for the details about a folder, and asking for the details about every item in a folder. ?fields works for both (and also works if you're doing a POST or PUT operation too).
If you want the details about a single folder: GET ./folders/<id>?fields=a,b,c
If you want the details about all the items inside a folder GET ./folders/<id>/items?fields=a,b,c

Related

Include categories custom fields in REST api

I am working with Advanced custom fields, where I add an image selector for categories in wp - But I can't see the data in my JSON response for categories?
I have tried to use several plugins to do the same, but That haven't worked either -
I am using ACF to rest plugin to include acf fields in the response, which works fine on custom post types - where it creates an array field called "acf"
This field is not created in my categories though - Am i missing a function to use it in taxonomies?
examples.
domain.com/wp-json/wp/v2/recipies (a custom post type)
returns everything including acf.
domain.com/wp-json/v2/categories (a texonomy)
returns all of the categories, but nothing about acf
domain.com/wp-json/wp/v2/categories/37 (a single category)
returns the category but nothing about acf.
domain.com/wp-json/wp/v2/categories/37?_embed[0] (way of getting all embedded stuff)
Does not show acf
Hope that you can put me on the right path.
To anybody who is interested, and runs into this problem.
I talked to the developer of acf-to-rest, and there is a bug in version 2, where it doesn't save taxonomies correctly - It is fixed in version 3, but you can't update it yet through wordpress, since it is still in beta -
Redownload the plugin and go into your wp-config file
here you need to define that you are going to use version 3. paste this line into the wp-config file
define('ACF_TO_REST_API_REQUEST_VERSION', 3);
The endpoints has been rewritten, so you also need to read up on that if you are using the acf endpoints for updating etc.
To read more about the bug, go github page
To read about the end points - go here
I hope that this will help somebody in the future.

Onenote does not return pages

This is similar question as OneNote pages API doesn't return pages in section-groups.
I'm using the Get sections and get Section pages with Sections expanded to get names for all pages in a notebook. However using the same requests all the time, the sections in section groups sometimes disappears, and wont reappear before recreating the group.
Is this a bug that one can somehow work around, or is there a better way of polling all the page names from a specific notebook? The pages need to be in order.
If you are trying to get all the page names for a Notebook, a work-around exists by using an OData nested filter. The idea is to query for all pages, $expand the parentNotebook, and then $filter on the id of the parentNotebook. Here is an example URL.
GET ~/pages?$expand=parentNotebook&$filter=parentNotebook/id%20eq%20'{$notebook_id_here}'
Here is another SO question where someone employs a similar pattern: Best way to use One Note API to GET specific pages in specific section in specific notebook?
Update:
You can control the order of the returned pages by using OData's $orderby and specifying properties that exist on the entities in the returned entity set (in this case, the entity is pages). From dev.onenote.com: "The default [order] is lastModifiedTime desc (most recently modified page first)."
Under https://dev.onenote.com/docs#/reference/get-pages there is a section, "Page properties", that shows all the properties returned by this call. Since we are getting all the pages available to a user that exist in a notebook, the only property we can use is unfortunately createdTime.
The query param to add looks like $orderby=createdTime
In full:
GET ~/pages?$expand=parentNotebook&$filter=parentNotebook/id%20eq%20'{$notebook_id_here}&$orderby=createdTime
I just tested this using Fiddler against my own pages so I think it should work. The nice thing is that it is a single request.
GET https://www.onenote.com/api/v1.0/me/notes/pages?$expand=parentNotebook&$filter=parentNotebook/id%20eq%20'{$YOUR_NOTEBOOK_ID_HERE}'&$orderby=createdTime

Scan an area of a web page's source code for changes while reporting it?

this is one heck of a confusing question to ask so here it goes. Firstly, I'm not asking you to write me any code I just need help going in the right direction for what I'm trying to achieve here. Basically the task is this, I want to scan a select area of a web page's source code for changes and if something does change, I want to report it somewhere (like a console or something). However, I do not want just a notification of change, I also want what the change is/was. I've been looking into things like jsoup but I am still struggling to even find out what this is called.
Any pointers would be insanely appreciated. Thanks, Optimistic.
Here are some steps assuming this is from a node.js project:
Get the URL for the specific script file you're looking for a change in.
Using the request() module, fetch that URL.
Break the data up into lines (probably using .split()).
Find the specific line you are looking for either by counting line numbers of by searching for some representative text in that line.
Using some sort of search in that line (perhaps a regex), find the current value of the exact item in that line you are looking for.
Save the current value.
Then, at some future time, repeat this whole process and compare what you find to the previous value.
If this is being done from a browser instead of node.js, then use an Ajax call to retrieve the file. If the file is on another domain from your web page and that domain does not permit cross-origin requests, then you cannot solve this problem in an automated fashion from a browser in your own web page.
Here is how I would do it with Jsoup:
Document doc = Jsoup.connect(url).get();
String scriptCssQuery = "script"; // Tune this CSS query to find THE script you need.
Element script = doc.select(scriptCssQuery).first();
if (script != null) {
String scriptLines = script.html();
// Store the changing line somewhere and compare it to its previous value...
}

existence or count of children in file resource?

The files resource, which is returned by the files.list and other methods, includes a list of parents for each file. It would be extremely helpful if files also included some indication of children. An integer property with the count of children would be best, but a Boolean flag indicating whether children exist would be fine. Could that be added to the API, Google folks?
I ask because I'm writing an application that displays an expandable tree of the user's Google Drive contents. The tree initially displays the top level of their drive with all folders collapsed. As the user expands folders, new queries are sent to the GD API to get the contents of each one. However, empty folders are to be displayed without an expansion icon at all. In order to do that, as the list of children in a folder is processed, if a child is a folder, another query must be run for that specific folder to discover whether it has children. It would be so much better if the files resource included a count of its children or a flag indicating their existence. It would reduce the number of queries, network traffic, and processing time.
I doubt very much it will happen. The issue is that there could be thousands of children and to include an array of that size within the file object would break and time out.
The children feed https://developers.google.com/drive/v2/reference/children/list is there for that specific purpose, and supports pagination.
Various work-around I found were all based on a looping solution over the children items count returned by each API call. Next API call must be then updated with the nextPageToken received from each response. A maxResult may be set to 1000 (max allowed).
Examples:
https://stackoverflow.com/a/16299157/490589 (C# version)
https://stackoverflow.com/a/17743049/490589 (Java version)

MSG Google Calendar adding a Feed

I know I must be brain-dead, and I had a solution about a month ago, but accidentally deleted it (oops)!
From the this page you can create a small widget calendar. With the date picker AND agenda (yes both are needed)
It produces some code like so:
<script src="http://www.gmodules.com/ig/ifr?url=http://www.google.com/ig/modules/calendar3.xml&up_calendarFeeds=&up_calendarColors=&up_firstDay=0&up_dateFormat=0&up_timeFormat=1%3A00pm&up_showDatepicker=1&up_hideAgenda=0&up_showEmptyDays=0&up_showExpiredEvents=1&synd=open&w=320&h=165&title=__MSG_Google_Calendar__&lang=en&country=ALL&border=%23ffffff%7C3px%2C1px+solid+%23999999&output=js"></script>
However it doesn't specify the calendar, and always loads the local calendar. I see there is the variable up_calendarFeeds in there, and that got me thinking I should try to add a feed. I searched and found google's page on feeds. The says the feed url is in the format of:
https://www.google.com/calendar/feeds/userID/private-magicCookie/full
full over basic is for machine readable, of which I assume the gadget uses. However when I set the up_calenderFeeds variable with my data, It loads nothing. What am I missing? This being my final code:
<script src="http://www.gmodules.com/ig/ifr?url=http://www.google.com/ig/modules/calendar3.xml&up_calendarFeeds=https://www.google.com/calendar/feeds/ohmusama#gmail.com/private-0b7544f4b5f2198fc76c96e59f285dad/full&up_calendarColors=&up_firstDay=0&up_dateFormat=0&up_timeFormat=1%3A00pm&up_showDatepicker=1&up_hideAgenda=0&up_showEmptyDays=0&up_showExpiredEvents=1&synd=open&w=195&h=500&title=Portland+IPA+Calendar&lang=en&country=ALL&border=%23ffffff%7C3px%2C0px+solid+%23999999&output=js"></script>
Alright, since no one was able to help me. I searched and searched and found some answers.
There are a variety of different variables in the get string with many characters that need escaping. First for what ever reason, up_calendarFeeds must be set to ({}) which url encoded ends up being up_calendarFeeds=%28%7B%7D%29
Then you need to set 2 variables for your calendar to work properly (I think you need both), up_c0u and up_c0c both to your feed path. Note that It seems this can be in an array form, so you can add many feeds by incrementing 0, so up_c1u up_c2u up_c3u etc