How to read BigQuery view using BigQuery REST API? - api

I have BQ table configuration in MAPPINGS and its view config_vw in SHARED_VIEWS data set.
Now I am trying to read the table and its view using REST API URI.
The table request GET https://bigquery.googleapis.com/bigquery/v2/projects/data-dev2/datasets/MAPPINGS/tables/configuration/data is responding correctly.
But when I am doing GET https://bigquery.googleapis.com/bigquery/v2/projects/data-dev2/datasets/SHARED_VIEWS/tables/config_vw/data for the view, it is giving below error.
{
"error": {
"code": 400,
"message": "Cannot list a table of type VIEW.",
"errors": [
{
"message": "Cannot list a table of type VIEW.",
"domain": "global",
"reason": "invalid"
}
],
"status": "INVALID_ARGUMENT"
}
}
Please suggest how to access BQ view using REST API ?
Regards,
San

It is expected that you cannot fetch data from a view using tabledata.list REST API.
VIEW is essentially a "saved query", which you need to make a query to materialize it into a table before you can use tabledata.list to fetch its data.
E.g., you can use jobs.insert API to run a query like
CREATE TABLE SHARED_VIEWS.materailized_config_vw
AS SELECT * FROM SHARED_VIEWS.config_vw
Then you can read SHARED_VIEWS.materailized_config_vw using tabledata.list.

Related

Microsoft Graph API odata $filter query does not appear to work

I am trying to filter a set of data returned by the MS Graph API's managedDevices endpoint using an odata filter.
Sending the request without a filter gets the expected result.
GET https://graph.microsoft.com/beta/deviceManagement/managedDevices
returns this response:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#deviceManagement/managedDevices",
"#odata.count": 5,
"value": [
{
"id": "kj23kj4-0d47-34f3-8ff0-6b5sdfsdf3332f",
"userId": "asdfasw-1b48-436d-aa42-3werwer2344",
"deviceName": "some_device_name_9/16/2020_6:31 PM"
...
When I send any of the following requests I get the exact same response with 5 results:
GET https://graph.microsoft.com/v1.0/deviceManagement/managedDevices?$filter=id eq 'kj23kj4-0d47-34f3-8ff0-6b5sdfsdf3332f'
GET https://graph.microsoft.com/v1.0/deviceManagement/managedDevices?$filter=id in ('lksjdf...','qwerqwer...')
GET https://graph.microsoft.com/v1.0/deviceManagement/managedDevices?$filter=ownerType ne 'personal'
I didn't see this listed on uservoice as an issue others are having specifically. They also apparently don't explicitly call out what odata query params are and aren't supported for specific endpoints. $select, for example, does work on this endpoint.
For this problem, I test it in my side also can't do the filter. And the odata url is correct, so I think the field id just not be designed to do filter.
If you want to do filter with id, you can use https://graph.microsoft.com/v1.0/deviceManagement/managedDevices/{id} directly. It can get the result with specific "id", maybe it is why the field id not be designed to do filter.

Cumulocity Inventory API filter by Creation Date

I'm currently trying to implement a simple date filter for the Inventory API using the query language. The filter should return a list of managed objects which were created after a given date. For some reasons I always receive an empty list as result but the example in the query language documentation looks the same as my query:
GET {{url}}/inventory/managedObjects?query=creationTime+gt+'2018-12-01T09:00:53.351Z'
gives me
{
"managedObjects": [],
"next": "{{url}}/inventory/managedObjects?query=creationTime+gt+'2018-12-01T09:00:53.351Z'&pageSize=5&currentPage=2",
"statistics": {
"currentPage": 1,
"pageSize": 5
},
"self": "{{url}}/inventory/managedObjects?query=creationTime+gt+'2018-12-01T09:00:53.351Z'&pageSize=5&currentPage=1"
}
And if I try this structure for the timestamp I even receive an error:
GET {{url}}/inventory/managedObjects?query=creationTime+gt+'2018-12-01T09:00:53.3512B1:00'
{
"error": "inventory/Invalid Data",
"info": "https://www.cumulocity.com/guides/reference-guide/#error_reporting",
"message": "Find by filter query failed : Query 'creationTime gt '2018-12-01T09:00:00'' could not be understood. Please try again."
}
Try to filter by
creationTime.date
Background is that the timestamps are stored as MongoDb dates.
You can also check the device list filter in device management which has a filter on creationTime as well.

INVALID_ARGUMENT exception when requesting Google's knowledge graph API

I've read the documentation on Google's knowledge graph and from what I understand we can search for results both based on a query and based on IDs. For getting results by a query, no problem whatsoever, but when I try to retrieve them by IDs, it fails. Setting aside what query I used myself, this is the request URL I got from Google's API Explorer:
https://kgsearch.googleapis.com/v1/entities:search?ids=kg%3A%2Fm%2F01nrz4&key={YOUR_API_KEY}
and the result is:
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT"
}
}
And I'm pretty sure that the problem is with the ids parameter. Am I missing something?
Thanks
OK, so here's the thing. Each found instance has an attribute like this: "#id": "kg:/m/0gkg6" . So in this instance the id is kg:/m/0gkg6, but when we want to run a query based on ID, we should omit the kg: part.

Marketo API error 1006: ignore fields that don't match

I am trying to do a simple Lead create/update via the Marketo API from a web form. I am posting data to multiple sources, not just Marketo, so I have other fields that don't match any fields during the Marketo update. This throws an API error of 1006 http://developers.marketo.com/documentation/rest/error-codes/
Here is an example JSON:
{
"action": "createOrUpdate",
"lookupField": "email"
"input": [
{
"firstName": "Matthew Edward",
"campaign_id": "testingCID",
"lastName": "King",
"email": "mking#umbel.com"
"message": "",
}
]
}
Since "campaign_id" and "message" aren't fields in the Lead capture, it throws the error and won't import anything. I would rather not write a function that cleans this data JUST for the the Marketo import. It would make future web forms more scalable if we didn't have to create a "blacklist" of fields that can't be imported into Marketo.
Is there anyway to avoid this error? Thanks.
This is by design. As you mentioned, the Marketo API will return the 1006 error code if a lead field you attempt to update does not exist in Marketo.
If writing a function that excludes this data is not an option, another option would be to create custom fields in Marketo for each custom field you need to update via the API.

How to add content and moreDetailsUrl for Google Search suggest?

I'm using GSA (version 6.14) and we would like to get an auto suggest function on our website. Works fine for basic requests, but it seems the GSA offers more functionality when you would be using user-added results. However, I can find nowhere a reference on how to add user-added results.
This is what the information tells me today :
/suggest?q=<query>&max=<num>&site=<collection>&client=<frontend>&access=p&format=rich
should return a response as below :
{
"query": "<query>",
"results": [
{ "name": "<term 1>", "type": "suggest"},
{ "name": "<term 2>", "type": "suggest"},
{ "name": "<term 3>", "type": "uar", "content": "Title of UAR",
"moreDetailsUrl": "URL of UAR"}
]
}
I am able to get results as the first 2 lines, but would like to get results as the last line also, so with content and a moreDetailsUrl. So maybe a very stupid question but I am not able to find the answer anywhere : How and where do I add this UAR ?
I actually want to understand if it's feasible to get metadata into the content part of the JSON, so if for instance an icon meta is available I'd like to have it included in the JSON so I can enrich my search results.
User Added Results are a OneBox that can be added to multiple frontends. See this: https://developers.google.com/search-appliance/documentation/614/admin_searchexp/ce_improving_search#uar
When done with Suggest, the data is fed from user entering 'keymatches' directly. What's different about them is that they are a direct link versus a suggested query. If you use the out of the box experience, you'll click a link to the url instead of running another query.