Google Sheets API. How to return result as a cell data only? - google-sheets-api

I'm complete newbie.
I have a 3rd party bot that can use APIs. The bot can understand links only. So I've made a link https://sheets.googleapis.com/v4/spreadsheets/(my spreadsheetID)/values/A12?key=(My key). But it returns me a lot of unnecessary info { "range": "'Sheet1'!A12", "majorDimension": "ROWS", "values": [ [ "My text is here" ] ]} And I want my bot to show me just "My text is here". Can I do that?
I tried to search. As I found, only parameters are majorDimension, valueRenderOption, dateTimeRenderOption. None of it gets rid of my problem. And other search results are with some coding, that my bot can't understand. Is there no way?

Related

Shopware 6 Store-API set newsletter recipient tags

I'm trying to add a newsletter recipient through store-api, which works. But when I try to add a tag inside the request, it fails. The documentation states that it is possible to add a tag as a string to the request, see here
My request looks like the following:
POST /store-api/newsletter/subscribe
{"option":"subscribe","email":"email#email.com","storefrontUrl":"http://myhost.test","tags":"men"}
I also tried to make the tags value an array, but this doesn't work either...
So my question is: how do I add a tag to the newsletter recipient through the store api?
As of Version 6.4.3.0 this seems not possible.
I tried the same request as you, as well as
"tags":["men"]
and
"tags":["uuidOfExistingTagGoesHere"]
all does not work.
Also the doc block for tags is wrong (it says "zip code" instead of a useful description).
In addition I tried to assign existing tags - this is what works via the admin API:
"tags": [
{
"id": "80df380188364f3c9bbaaa4d6b993dbd"
},
{
"id": "108428f0a37c4d11a66976adc5337c23"
}
]
Which still returns
"code": "FRAMEWORK__WRITE_MALFORMED_INPUT",
"title": "Bad Request",
"detail": "Expected data to be array.",
Also looking at the code there currently seems no handling of the tags. As far as I understand it, the tags would needed to be created on the fly
A possible fix would be the following code:
if (isset($data['tags']) { // inserted that lines
$data['tags'] = $data['tags']->all();
} // end inserted lines
$data = $this->completeData($data, $context);
Using that line, the last mentioned request works (you could then use the IDs of existing newsletter recipient tags).
Of course in this case the API docs have to be adapted.
TL;DR
In my opinion, this seems a flaw in the current Store API implementation.
I would suggest to create an issue on the Shopware 6 issue tracker.

ImportXML google sheet for shipment package tracking

I want to track each FEDEX, DHL and UPS shipment status directly from google sheets. I am using importxml function:
=IMPORTXML("https://www.fedex.com/apps/fedextrack/?action=track&tracknumbers="&C2&"&locale=en_US&cntry_code=us","//h1/div[#class="redesignSnapshotTVC snapshotController_addr_label dest"]/title")
However it shows error.
Attaching my sheet link for this: https://docs.google.com/spreadsheets/d/1E1L0rn9-H4MCutI1On2uHDkkPo1pdjRpv014YREGIdU/edit?usp=sharing
Please tell what is best way to do it. I am from non tech background.
Thanks so much for help!
Common issue. You're trying to import html that is generated after loading. That means we have to look for how the data you want is generated.
Data source
Upon inspection of the site, I found that it was making an XHR to the URL https://www.fedex.com/trackingCal/track, and that it was doing so via POST with a long payload. The response was in JSON format. Of note, there is the scanEventList entry.
"scanEventList": [{
"date": "2020-07-15",
"time": "13:15:00",
"gmtOffset": "-07:00",
"status": "Delivery exception",
"statusCD": "DE",
"scanLocation": "SAN BERNARDINO, CA",
"scanDetails": "Future delivery requested",
"scanDetailsHtml": "",
"rtrnShprTrkNbr": "",
"statusExceptionCode": "17",
"isClearanceDelay": false,
"isDelivered": false,
"isDelException": true,
"isException": true
},
...
]
Solution
First, get the ImportJSON script from GitHub, and add it into your sheet's scripts (Tools > Script Editor). It's not the most amazing thing, but it will at least give us ImportJSONViaPost() to get the data we want:
=INDEX(ImportJSONViaPost("https://www.fedex.com/trackingCal/track","data=%7B%22TrackPackagesRequest%22%3A%7B%22appType%22%3A%22WTRK%22%2C%22appDeviceType%22%3A%22DESKTOP%22%2C%22supportHTML%22%3Atrue%2C%22supportCurrentLocation%22%3Atrue%2C%22uniqueKey%22%3A%22%22%2C%22processingParameters%22%3A%7B%7D%2C%22trackingInfoList%22%3A%5B%7B%22trackNumberInfo%22%3A%7B%22trackingNumber%22%3A%22"&A2&"%22%2C%22trackingQualifier%22%3A%22%22%2C%22trackingCarrier%22%3A%22%22%7D%7D%5D%7D%7D&action=trackpackages&locale=en_US&version=1&format=json",,"/TrackPackagesResponse/packageList/scanEventList,/TrackPackagesResponse/packageList/trackingCarrierDesc","noHeaders"),1)
Arguments:
URL for the tracker
The POST payload. Cell A2 Holds your tracking number.
Leave empty
Query - Lets us select the data that we want. In this example, I chose to select the carrier description and the entire scanEventList entry, but you can specify particular elements of that as well.
"noHeaders" means just the data.
Just using the JSON import gives us an entry for each element of scanEventList, but the first is the most recent, so, we use INDEX to retrieve the first entry, which should contain what you need.
For additional help on the ImportJSON package, see here.

Text Recognition failing to recognize currency symbols

I am using the text recognition API within mobile vision, and trying to work with currency amounts. The OCR currently supports Latin based languages like French, German, etc., so I figured the country's currency (Euro) would be a recognized symbol, but as far as I can tell, it's not.
Are there language preferences that I should be changing in order to detect €? Does anyone have experience working with currency symbols within mobile vision as well, or is it just not currently supported?
Thanks!
I also would like to know if the Google Mobile Vision API can be configured to recognize the € symbol.
With other OCRs, like Tesseract, you can specify a white list and a blacklist of characters - like only numbers, only text, or text, numbers and € symbol.
If this does not work with the Google Mobile Vision API, it is a major limitation, and it can't be used for many use cases.
No it does not support recognizing symbols.
Try set languageHints, it helped me with the same problem
{
"requests": [
{
"image": {
"source": {
"gcsImageUri": "gs://YOUR_BUCKET_NAME/YOUR_FILE_NAME"
}
},
"features": [
{
"type": "TEXT_DETECTION"
}
],
"imageContext": {
"languageHints": [
"en", "fr"
]
}
}
]
}

Which fields are required to create an event through Social Tables API

I have the following questions that I was not clear on from the API documentation:
Which fields are required to create an event?
What does "Invalid field: 0" mean? (this was an error message received when trying to create an event)
The sample body includes "spaces" as string -- is this the space name or ID?
Is this required? If yes, to create a space I need an event ID but to create an event do I need a space?
Hey thanks for using our API. It looks like the developer docs on our portal got kind of mangled. We'll be working on fixing that soon.
In the meantime, let me try to help.
So, the actual required fields for that endpoint are very minimal, here is a small sample post I made for a room here at Social Tables:
{
"name": "Dan's Office Party",
"category": "Other",
"spaces": [
{
"name": "st test"
}
]
}
The key thing here is that spaces is an array, with at least a name property attached.
The error message you referred to is a failing validation check on the type of one of the fields you submitted.
You do need a space to create an event, but as you can see, only the name is absolutely required. However, if you want to do any diagramming with that event, you'll probably want to attach a venue_id with one of our floorplan IDs in addition to the name property.
I have created an issue to update the mangled doc located at https://developer.socialtables.com/api-console#!/Events/post_4_0_legacyvm3_teams_team_events and will comment here when it is updated.

How to move an item from one parent to another?

I have a parent type call TaskList. A TaskList has many Tasks.
The simple case question that I have is how to move a Task from one TaskList to another.
I run a search query to find the set of Tasks that I want to move. The Tasks then are in the _embedded attribute of the JSON that comes back from that search. I want to then move those elements to a different TaskList. How would I do this?
Would I submit a POST to /tasklists/x with the _embedded Tasks as the body of that request?
Would I submit a PATCH to /tasks/y with a tasklist_id attribute already set?
What's the proper way to do this?
Thanks!
Moving a task implies that it already exists and has a URI. You POST that URI to the URI of the target task list.
The appropriate content type is text/uri.
As you suggested, you could submit a patch request according to : https://www.rfc-editor.org/rfc/rfc6902#section-4.4
Your json would look like something like this :
[
{
"op": "move",
"from": "/tasklists/id/tasks/id",
"path": "/tasklists/anotherId/tasks/id"
},
{
"op": "move",
"from": "/tasklists/id/tasks/id2",
"path": "/tasklists/anotherId/tasks/id2"
}
]
Hope it helps !
I'm using spring-data-rest on the server. What I ended up doing was sending a patch request to the item URL that looks like this:
{TaskList:"http:/host:port/tasklists/id"}
Here's a reference to a post which game me some insight.
https://stackoverflow.com/a/26426909/1174250
Thanks everyone for your comments :)