Can you include multiple labels in the same PDF using shippo.transaction.create({...}) - shippo

I am creating a new transaction object and purchasing the shipping label with one API call using shippo.transaction.create({...}). My user can request 1 or more of the same label at the same time. How can I include the number of labels they requested in the same PDF? I really don't want to do it in a batch since this is much quicker and straight-forward.
I have tried looping through
shippo.transaction.create(
{
shipment: shipment,
carrier_account: carrierAccount.object_id,
servicelevel_token: shipDetails.shippingMethod,
label_file_type: 'PDF',
})
but only ever get 1 back in return. This PDF will be either emailed or printed directly by the user.

As far as I understand, we don't have an option to download/aggregate multiple labels into one PDF file via API/SDK.
Batch API can be used to group the purchased labels. This API will aggregate the label into one single PDF as well.
Once your purchases are complete, you will be able to download a
merged PDF file with the labels. Each PDF file will contain up to 100
labels, the label_url field will contain an array of PDF files.
You can read about this further here: https://goshippo.com/docs/batch/
I am checking with my team as well. I will edit/add a comment if I find a workaround or an alternate solution.

Related

Simple way to call a REST API from an excel cell, hopefully without VBA

I have a column of hundreds of parcel tracking numbers, and I want to use the parcel carrier's REST API to pull some of the tracking information (promised delivery date, and actual delivery date) and then use conventional spreadsheet techniques on it.
Is there a simple way to put the REST call in a formula in an excel cell? in pseudocode it would be call this REST url, using the tracking number in the cell to the left as an argument, and here's the authentication user/password, and return the value in the response field 'deliveryDate'
I am intrigued by Power Query and I figured out how to use Power Query to do it for a static REST url with the tracking number manually filled in, but I don't know how to make PQ do it for hundreds of items.
or maybe there is an online tool for building this function with lego blocks for a caveman like myself?

SharePoint REST API returns incomplete content of file during downloading

I work on application for fetching and downloading SharePoint data. For every folder in SharePoint I can get the list of all files inside given folder by using next SharePoint REST API endpoint:
/_api/web/GetFolderById('<folder_guid>')/Files
The expected size and guid is provided for every file so I can use them when I want to download the file. Then I use the next endpoint from SharePoint REST API in order to actually get file content:
/_api/web/GetFileById('<file_guid>')/$value
From time to time when I download the file I get less data than expected: size of downloaded data is just different from the value I obtain while getting the properties list of files. However when I try to get its content again it can be successfully downloaded (size of downloaded data is equal the expected value) or I can get another incomplete data.
I verified that the first endpoint (one used to get properties of all files in the folder) returns the correct file size. The problem is in the call of the second one.
I see that there is "transfer-encoding" header with "chunked" value in response. So when my http client performs chunked data download and if zero chunk is received at some point then we reached the end of the body by definition. So it looks like in some cases SharePoint either returns the incomplete data or zero chunks when they should not be sent.
What can be the reason of such strange behavior? Is it a know issue?
We actually also see this, strange behaviour, many files are just small aspx files, about 3-4kb and they are constantly smaller by 15% and more than appears in file propertis. We're also using REST API and this is really frustrating. All those strange bugs in Sharepoint Online are very annoying.
this is an interesting topic... are those files large? like over 1GB? It would seem that chunk file download is not supported way in SP Online. Better option is to user RPC. Please see this links for examples:
https://sharepoint.stackexchange.com/questions/184789/download-large-files-from-sharepoint-online
https://social.msdn.microsoft.com/Forums/office/en-US/03e55d41-1daf-46a5-b61d-2d80139123f4/download-large-files-using-rest?forum=sharepointdevelopment
https://piyushksingh.com/2016/08/15/download-large-files-from-sharepoint-online/
You could also check the MS Graph API if maybe will work better for this case
https://learn.microsoft.com/en-us/graph/api/driveitem-get-content?view=graph-rest-1.0&tabs=http
... I hope this will be of any help

How to organise REST endpoints for a drop-wizard application?

I am new to dropwizard and REST.
My sample application is a order viewing system. Currently, I am working on a functionality where the UI page consists of set of order search criteria, search button, and link to download the search result as CSV. Download link is displayed only after the successful search. The application has to write the search result to a CSV file and the file location returned will be used to download the file.
I need help in organising the endpoints for this.
Initially, I thought of an end point GET - /orders - text/JSON with search criteria passed in as query params. But, since I will be actually creating the CSV for every GET request, I am wondering if I am violating the HATEOAS rest constraint for the GET (resource should not be created). Or, since the actual resource is Order and not the CSV, is it ok to have the endpoint as GET?
Or, do I need multiple endpoints adhering to the REST constraints and conventions interacting with each other to produce the required result?
Like:
1.POST - /orders/csv - text/json (file name) : creates the CSV file of orders and returns the JSON of file name.
2.GET /orders/csv/<file_name>: gets the file to download.
Many thanks for your help.

What's the most efficient way to get all emails with a specific type of attachment over IMAP?

From what I can tell, IMAP SEARCH doesn't support searching by if an email has attachments (except Gmail's variation, which I'm not interested in...I need a general IMAP solution). Is that correct?
Assuming that's the case, my understanding is that I have to issue a FETCH and filter on the client side.
If this is correct, what's the FETCH that will yield the smallest amount of information that will allow me to filter by attachment type? I believe it's FETCH BODYSTRUCTURE, but I'd like confirmation.
I looked at FETCH BODY[MIME], but it appears that needs a section number (or numbers) and MIME can't be used by itself. I believe that there can be any number of sections and subsections, and theres no way to specify to search all sections. Is that correct?
I'm looking for a protocol level answer. I don't need an answer using any specific language or library.
Thanks!
Generally, to get all attachment, you look for their number and names first in imap_fetchstructure->parts, it's an array of file names.
Then to get file content you need to get imap_fetchbody and add 1 to it.
For example, attachment number one is found on section number 2.
I created my Imap solution and it's working well.
based to that you can add you search section

Multiple tags / folders in Google Reader

I want to be able to grab data from multiple tags / folders in a users Google Reader.
I know how to do one http://www.google.com/reader/atom/user/-/label/SOMELABEL but how would you do two or three or ten?
Doesn't look like you can get multiple tags/folders in one request. If it's feasible you should iterate over the different tags/folders and aggregate them in your application.
[edit]
Since it looks like you have a large list of tags/folders you need to query, an alternative is to get the full list of entries, then sort out the ones the user wants. It looks like each entry has a category element that will tell you what tag is associated with it. This might be feasible in your case.
(Source: http://code.google.com/p/pyrfeed/wiki/GoogleReaderAPI)
(Source: http://www.google.com/reader/atom/user/-/state/com.google/starred)
I think you cannot get aggregated data as you hope to be able to. If you think about it, even Google lets you browse folders or tags one at a time, and do not aggregate a sub-set of them.
You can choose to have a list of all the items (for each one of their available statuses) or a list of a particular tag/folder.
You could do it in 2 requests. First you need to perform a GET request to http://www.google.com/reader/stream/items/ids. It supports several parameters like
s (required parameter; stream id to fetch; may be defined more than one time),
n (required; number of items to fetch)
r for ranking (optional)
and others (see more under /ids section)
And then you should perform a POST request (this is because there could be a lot of ids, and therefore the request could be cut off) to http://www.google.com/reader/api/0/stream/items/contents. The required parameter is i which holds the feed item identifier (could be defined more than once).
This should return data from several feeds (as returned for me).