Closed bobchatham closed 3 years ago
You will need to add Content Type
as application/json
in header.
https://docs.api.lens.org/getting-started.html#http-responses
Also, please don't paste your actual access token publicly. Please delete it and gererate a new one.
This should work.
var query = {"query": { "terms": { "lens_id": ["162-510-171-350-158"]} }, "include": ["claims"]};
var options = {
'method': "POST",
'url': endPoint,
'payload': JSON.stringify(query),
'json': true,
// muteHttpExceptions: false,
'headers': {
"Authorization": "Bearer " + token,
"Content-Type": "application/json"
}
};
Thanks for the help Roshan, your suggestion worked.
I'm now coming up with a plan for dealing with the rate-limiting so that a typical spreadsheet user won't overrun the limits but still realize acceptable performance. The 6 (maybe 10?) calls/minute limit seems low, but fine for development purposes for now. Would retrieving an array of patents using a vector of n lens_ids count as one call or n calls?
Yes, you can retrieve multiple lens ids (up-to 100 for trial) in a single request like this:
{
"query": {
"terms":{
"lens_id": ["162-510-171-350-158", "....", "....."]
}
},
"include": ["claims"]
}
It will be a single request. You can use scroll based pagination to loop through and sleep for response code 429
(too_many_requests) like this:
https://docs.api.lens.org/samples-patent.html#cursor-based-pagination
We're building a function library to the patents API to support Excel and Google Sheets users. I've successfully gotten the following code to work from VBA in Excel on Windows, but am stuck on Google Apps Script in Sheets:
I'm now trying to get this to work in Google Apps Script (ECMAScript). So far totally unsuccessful, always get a 415 return code despite trying a bunch of permutations of double and single quotes, JSON.stringify'ing the POST inputs, header parameters etc. (see various permutations commented out below)
I have given the script the appropriate OAuth permissions (I think...see below). Would love to get this to work -- any suggestions? Thanks in advance. Bob
Code.js
appsscript.json