How to get the link data with pretty text in it from Google Sheet API - api

I'm getting data from google sheet in CSV format. But when the sheet has a Hyperlink in its cell, like =Hyperlink("URL", "pretty text"), the google sheet only gives me the pretty text not the link, So my question is how can I get both links & pretty text from google sheet.
Thanks for helping me

You will have to make use of the valueRenderOption parameter when making the spreadsheets.values.get API call.
Assuming your cell looks like this:
You can retrieve the following values using different values for the valueRenderOption parameter as this one will determine how values are rendered in the output.
1. If valueRenderOption is FORMATTED_VALUE (which is the default value when making the API call):
GET https://sheets.googleapis.com/v4/spreadsheets/SPREADSHEET_ID/values/A1?valueRenderOption=FORMATTED_VALUE
Then the response will look like this:
{
"range": "Sheet1!A1",
"majorDimension": "ROWS",
"values": [
[
"pretty text"
]
]
}
2. If valueRenderOption is UNFORMATTED_VALUE:
GET https://sheets.googleapis.com/v4/spreadsheets/SPREADSHEET_ID/values/A1?valueRenderOption=UNFORMATTED_VALUE
Then the response will look like this:
{
"range": "Sheet1!A1",
"majorDimension": "ROWS",
"values": [
[
"pretty text"
]
]
}
3. If valueRenderOption is FORMULA:
GET https://sheets.googleapis.com/v4/spreadsheets/SPREADSHEET_ID/values/A1?valueRenderOption=FORMULA
Then the response will look like this:
{
"range": "Sheet1!A1",
"majorDimension": "ROWS",
"values": [
[
"=HYPERLINK(\"URL\", \"pretty text\")"
]
]
}
Therefore, depending on the exact result you want to achieve, it would be best to use the FORMULA parameter as this will retrieve the formula with its link and value as well. This might require some string processing if you simply want the link and its value.
Reference
Sheets API spreadsheets.values.get;
Sheets API ValueRenderOption.

Related

Zabbix pre-processing item get item within an array with javascript

I don't have any experience with Javascript so I'm reaching out for the community to accomplish the below.
I have a few API calls configured on Zabbix which are working just fine. The thing is, not all of the results within an item is importante for me so I need to grab just what I want out of the array.
I'm using the pre-processing option on Zabbix to grab what I'm after but I can't get the code correct.
For instance, the below is one of the results Zabbix is getting.
[
{
"batteryLife": "15 minutes",
"communityString": "public",
"instanceId": "260596.1",
"instanceName": "UPS-01",
"ipAddress": "10.1.100.44",
"modelNumber": "GXT4-10000RT230",
"name": "UPS-01",
"objectType": "ScUps",
"scName": "pth-pf-04",
"scSerialNumber": 260596,
"serialNumber": "unknown",
"status": "Up",
"statusDescription": "Online",
"type": "Liebert"
}
]
How Can I Use the pre-processing to grab just the "ipAddress" value for instance?
Thanks for the help.
PeteF
You can avoid JavaScript preprocessing where you can use JSONPath preprocessing, see https://www.zabbix.com/documentation/current/manual/config/items/preprocessing/jsonpath_functionality
In your case:
$[0].ipAddress
A useful tool for JSONPath is http://jsonpath.com/
In case someone have the same doubt as I was having here is how I got it working to return the "ipAdress" value
var json = JSON.parse(value);
return json.ipAddress;
In case there are more than one dictionary inside of an array.
var json = JSON.parse(value);
return json[0].ipAddress;

How to SelectFrame dynamically in Salesforce?

I am trying to automate a script using Kantu in Salesforce.
Basically I am going through some dropdown IDs and select the right values and everything works IF the selectFrame value is correct in the beginning.
The problem is that Salesforce refreshes the iframe ID everytime the page is refreshed or a new case is opened (i.e. ext-comp-1018 | ext-comp-1035 | ext-comp-1048 etc.)
Because the script does not recognize the frame (since it is always changing), it won't go ahead to do the rest of the actions.
{
"Name": "SFDC_Auto",
"CreationDate": "2019-3-25",
"Commands": [
{
"Command": "selectFrame",
"Target": "id=ext-comp-1018",
"Value": ""
},
{
"Command": "select",
"Target": "id=cas5",
"Value": "label=Escalation"
},
I seen a post that mentioned this would be the solution, but I am not sure how to implement it in Kantu:
frames = #driver.find_elements(:xpath, '//iframe[starts-with(#id,ext-
comp-)]') #driver.switch_to.frame frames1
So far I could make this work: xpath=//iframe[starts-with(#id,ext-comp-)], however it doesn't do nothing. It reads ok but then halts at the next step saying that ID CAS5 is not recognized.
Can anyone help out?
Thanks,

Google Vision Text Detection returns too much unnecesary data

When using Google Vision to run text detection on a menu, the response from their API is way too large and returns way too much data that I don't need. I just want the text from the menu, not all the coordinates that come with the response. I can't find anything about narrowing down the response in any documentation i've read. Does someone know how to specify what fields get returned in the response?
Heres my request:
POST: https://vision.googleapis.com/v1/images:annotate?key=<MY_KEY>
BODY:
{
"requests": [
{
"image": {
"content": "...base64-encoded-image-content..."
},
"features": [
{
"type": "TEXT_DETECTION"
}
]
}
]
}
I figured it out. I could not find any documentation on how to do this, I had to just guess for like half an hour. If someone knows of any documentation on this let me know.
Anyway you can use the "fields" parameter to narrow down the response like so:
POST: https://vision.googleapis.com/v1/images:annotate?key=<MY_KEY>&fields=responses.fullTextAnnotation.text
This will only return the menu text from the Google Vision text detection API

Remove auto-link formatting from Google Sheet via api

When using Google Sheets Api to create automated reports I've found that any string that ends with ".com" automatically gets formatted as a link (I've attached a picture). I'd like to remove this formatting via the api, Is this possible?
Two examples of the autolink formatting
You can change the hyperlink format to the plain text format using "hyperlinkDisplayType". The endpoint and request body are as follows. As a sample, the request body removes the hyperlink format of cells "A1:A3". I thought that from the image of your question, repeatCell might be suitable for your situation.
Endpoint :
POST https://sheets.googleapis.com/v4/spreadsheets/### spreadsheet ID ###:batchUpdate
Request body :
{
"requests":
[
{
"repeatCell":
{
"cell":
{
"userEnteredFormat":
{
"hyperlinkDisplayType": "PLAIN_TEXT"
}
},
"fields": "userEnteredFormat.hyperlinkDisplayType",
"range":
{
"sheetId": sheetId,
"startRowIndex": 0,
"endRowIndex": 3,
"startColumnIndex": 0,
"endColumnIndex": 1
}
}
}
]
}
Note :
This answer supposes that you can use Sheets API.
Reference :
HyperlinkDisplayType
RepeatCellRequest
If I misunderstand your question, I'm sorry.

How can I use REST url as data in Vega-lite

I have this REST API that returns tabular data in the following way:
{"data": [{"el1": 8, "el2": 9}, {"el1": 3, "el2": 4}]}
I would like to use el1 and el2 in a Vega-lite chart. How should I refer to the elements in the array?
From the documentation here:
(JSON only) The JSON property containing the desired data. This parameter can be used when the loaded JSON file may have surrounding structure or meta-data. For example
"property": "values.features"
is equivalent to retrieving json.values.features from the loaded JSON object.
It seems that you can try to specify the "property" property (punny, eh) on the format. Something like this:
"data": {
"url": <your url here>,
"format": {
"type": "json",
"property": "data"
},
}
Disclaimer: I haven't actually tested this but it looks to be supported (: