Request Sync always returns 404 : "Error: Requested entity was not found." - actions-on-google

I'm having a hard time implementing requestSync. It always returns
"error": {
"code": 404,
"message": "Requested entity was not found.",
"status": "NOT_FOUND"
}
I use Node.js/Express for the backend. The linking/unlinking with the Google Home app work and my actions work as well. It's really the requestSync part that fails.
The closest ticket I've found, though not exactly the same, is this one.
Things I've tried
agentUserId is a string, but if I pass it a number it returns a 400 with the message "Invalid value at 'agent_user_id'".
tried sending agent_user_id instead of agentUserId, this returns a 404 the same error as when I send a agentUserId
tried removing the "async:true" part of the body. did not notice a difference.
during SYNC, hardcoded the value of the agentUserId to eliminate possibility that I'm sending the wrong one. I use that same agentUserId during requestSync and this fails.
tried linking/unlinking multiple times in the google home app
another interesting thing to note : when opening up the "Test Suite" from the actions on google console, I put in that same agentUserId + service account key, and it registers it well : I'm able to see my devices listed correctly. Which leads me to believe that my agentUserId is correct (this may be a false assumption)
I'm 100% sure HomeGraph is enabled as I can see data on the charts in the "Overview" section of the HomeGraph API part of the console.
This is what the curl looks like (same as from the example)
curl -i -s -X POST -H "Content-Type: application/json" -d "{agent_us
er_id: \"1\"}" "https://homegraph.googleapis.com/v1/devices:requestSyn
c?key=API_KEY"
(my agentUserId is 1 in this case)
And this is what it looks like in code :
const res = await fetch(
`https://homegraph.googleapis.com/v1/devices:requestSync?key=${config.googleApiKey}`,
{
method: 'POST',
body: JSON.stringify({
agentUserId: String(userId),
async: true,
}),
headers: { 'Content-Type': 'application/json' },
},
);
Regardless of what I do, the result is always :
"error": {
"code": 404,
"message": "Requested entity was not found.",
"status": "NOT_FOUND"
}
I don't know where else to look to identify this problem. Any pointers would help. Thank you

Finally found the answer.
It wasn't too far from the one I had posted above. Although my problem is that when I generated an API key, the google home cloud console opened the wrong project by default. I had the wrong API key all along.

Related

GET request to Patch Management API (Patch Manager Plus - Cloud)

I followed the instructions in the Patch Manager Plus - Cloud (https://www.manageengine.com/patch-management/api/) . And then get information (like refresh_token, client_id, client_secret), get access_token for every hour.
When trying to initiate a GET request to api/1.3/som/computers, I get the following response back.
{
"message_response": "Unable to retrieve details, Please try again later.",
"error_code": 90004,
"error": "invalid input found",
"message_version": "1.0",
"status": "error"
}
My code is as follows:
axios.get('https://patch.manageengine.com/api/1.3/som/computers', {
headers: {
"Authorization": << access_token >>
}
})
I think there is a problem with the header such as missing some parameters. (I tried running the api in the browser (logged in) and got the data). I also searched but couldn't find a description for this part.
Can anybody help me, please?

How to make a call to Firestore using gRPC

I'm trying to build a gRPC client for Google's Firestore API in Elixir.
Before starting to write some code , I thought that it would be wise to first start with BloomRPC in order to debug the issue.
As base url, I'm using https://firestore.googleapis.com where I pinned the rot certificate.
As auth I'm using an access_token obtained using oauth with the following 2 scopes: "https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/datastore"
being passed as a Authorization header:
{
"Authorization": "Bearer 29ya.a0AfH6SMBDYZPsVgQv0PMqyGRXypc3DfWF_2jbvAJKMquTaryCvxEB7X1Rbprfk1Ebrwid2bXbcR3Aw-d1Tytlo_lThkyqRDRIbnSz5-nQ3xWklkmjyFMAuQtFCoz01hk3vbgBwd2gdbFNNWiOU_8NqPC_vElyz2-cQ34"
}
And I get back:
{
"error": "3 INVALID_ARGUMENT: Missing required project ID."
}
So clearly I should be passing the project ID somehow but I can't find it anywhere in the docs. Anybody any clues?
I just figured out what I was doing wrong.
Basically the Bearer token I was using is correct (obtained via the OAuth Playground).
The trick was to specify the PROJECT_ID in the parent parameter of the request:
{
"parent": "projects/[project-id]/databases/(default)/documents",
"page_size": 10
}
I should have just read the docs properly :)

"message": "Unsupported post request. Object with ID does not exist, cannot be loaded due to missing permissions

I have two apps on facebook. In one, I can make API calls. In the other, I can not.
I checked the configuration and the settings are the same.
Can you help me?
Example: https://graph.facebook.com/860599774051206/?access_token=APP_ID|APP_SECRET
https://graph.facebook.com/860599774051206/notifications?template=#[860599774051206]test&access_token=APP_ID|APP_SECRET&method=post
the error is:
{ "error": { "message": "Unsupported post request. Object with ID
'860599774051206' does not exist, cannot be loaded due to missing
permissions, or does not support this operation. Please read the Graph
API documentation at developers.facebook.com/docs/graph-api",
"type": "GraphMethodException", "code": 100, "fbtrace_id":
"BRW7BqFeEER" } }
RESOLVED:
Any app can change the user_id
In an app the user_id is 962084030569446, in the other 860599774051206
Thakns for all.
I faced this issue when I was trying to post a response to an user from a page. I used the graph API me/accounts and got the list of pages. From there I retrieved the access_token of the page from which I'm going to post the response. I got the same error mentioned in the question.
The issue for me is the user account to which I was supposed to respond is locked due to security. This is the error I got from facebook when I tried to login
You can't use Facebook at the moment
This is the error I got for the post api call
{
"error": {
"message": "Unsupported post request. Object with ID 'xxx' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100,
"error_subcode": 33,
"fbtrace_id": "yyy"
}
}
Once the account security is resolved, the issue is resolved.
While unrelated to the OP problem I thought I would contribute, I got this error when posting to the Offline Events endpoint https://graph.facebook.com/v2.8/<business_id>/events. I had posted from a node.js app successfully, then when porting the approach to a .Net implementation in our Linnworks order management system, got this error.
Turned out, I had mis-typed the access_token parameter that goes in the form data, i.e.
System.Collections.Specialized.NameValueCollection formFields = new System.Collections.Specialized.NameValueCollection();
formFields.Add("accessToken", accessToken);
formFields.Add("upload_tag", "store_data");
formFields.Add("data", data);
Should have been:
System.Collections.Specialized.NameValueCollection formFields = new System.Collections.Specialized.NameValueCollection();
formFields.Add("access_token", accessToken);
formFields.Add("upload_tag", "store_data");
formFields.Add("data", data);
Getting the access_token field wrong in this way caused this 'Object with ID does not exist' which is a bit of a red herring. I guess that, once the access_token value was not provided, no objects could be enumerated in our account because the request didn't authenticate in order to provide permissions, and so the object was 'not found'
(you do not have to use NameValueCollection, this is just a by-product of me using the multipart post implementation suggested here Upload files with HTTPWebrequest (multipart/form-data))
In my case - I had to use the app-id to get the list of pages using me/accounts.
Once I identify the page that I want to post the message to, I have to use the page-id to feed page-id/feed.
This solved the issue.
For example:
$response = $fb->get('/me/accounts', (string)$selBehRow1["fb_app_access_token"]);
foreach ($response->getDecodedBody() as $allPages)
{
foreach ($allPages as $page )
{
if (isset($page['id']) && $page['id'] == $selBehRow1['fb_page_id'])
{ // Suppose you save it as this variable
$appAccessToken = (string) $page['access_token'];
break;
}
}
}
$response = $fb->post(
//this is wrong: '/'.$selBehRow1["fb_app_id"].'/feed',
'/'.$selBehRow1["fb_page_id"].'/feed',
array(
"message" => "$msg",
"link" => "$link",
//"picture" => "http://www.example.net/images/example.png",
"name" => "$name",
"caption" => "$caption",
"description" => "$description"
),
$appAccessToken
);
}
i think post_id is wrong you can check it once
https://graph.facebook.com/860599774051206_4548643168486465/?access_token=APP_ID|APP_SECRET
https://developers.facebook.com/docs/graph-api/reference/v3.3/object/comments
use this api for replies to the post
Method: POST
https://graph.facebook.com/860599774051206_4548643168486465/comments?access_token=APP_ID|APP_SECRET
body:
{
"message": "Thanks"
}
You need to use GET request instead POST. Look at the documentation
In my case I needed to Complete Setup

Google Fit REST API "Unable to fetch DataSource for Dataset: xyz"

I'm testing out a few things in the OAuth 2.0 Playground and trying to get data in and out of Google Fit using their REST API
I have done this previously with success, I just didn't write down what I did.. now I've come back to make it a proper thing and can't get it working again.
I have access to Google Fit datasources via the dashboard. I can get a list of the dataSources that exist from:
https://www.googleapis.com/fitness/v1/users/me/dataSources
And that is successful. I have also created my own stream which has a single floating point weight value on it called
raw:com.google.weight:b6ac18c0:dten.sync
It already has data in it, I put it there last time I used it. I can select all that data by requesting a GET on the following
https://www.googleapis.com/fitness/v1/users/me/dataSources/raw:com.google.weight:b6ac18c0:dten.sync/datasets/0-1432193482000000000
It returns me all the data points I entered last time as JSON
I then try to PATCH the data adding my own data to the folliwng URL
https://www.googleapis.com/fitness/v1/users/me/dataSources/raw:com.google.weight:b6ac18c0:dten.sync/datasets/1432193482000000000-1432193482000000000
With this as a the request body
{
"minStartTimeNs": "1421912895000000000",
"maxEndTimeNs": "1432193482000000000",
"dataSourceId": "raw:com.google.weight:b6ac18c0:dten.sync",
"point": [
{
"startTimeNanos": "1421912895000000000",
"modifiedTimeMillis": "1421912895000",
"endTimeNanos": "1421912895000000000",
"value": [
{
"fPVal": 89.1
}
],
"dataTypeName": "com.google.weight"
}
]
}
But I get back
{
"error": {
"code": 400,
"message": "Unable to fetch DataSource for Dataset: raw:com.google.weight:b6ac18c0:dten.sync",
"errors": [
{
"domain": "global",
"message": "Unable to fetch DataSource for Dataset: raw:com.google.weight:b6ac18c0:dten.sync",
"reason": "invalidArgument"
}
]
}
}
I can't find any one referencing a similar anywhere soo I'm here
Also note if I miss spell my source it tells me off because they don't match the URL, if i include an empty list of data points I get the same error. I'm quite lost so I'm throwing it out there to see if anyone knows what that means
Thanks in advance
edit: i tried changing the hex code for my project's integer code and got an error about untrusted source. so i tried making a new test data source which works as expected. Slightly annoyed but guess I'll just start over..
OK I was stupid and didn't set up my own credentials in the OAuth settings in top right of the dashboard as it said to here. I forgot that bit -_- now I can access my own stream again and it shows my integer project id in the stream id not the hex one
https://developers.google.com/fit/rest/v1/get-started
Now I get invalid argument, but.. whatever >_<
edit 2:
invalid argument was because I have fPVal instead of fpVal and modifiedTimeMillis mills is not supposed to be submitted, obviously

Marketo "Import Lead" fails with error 610 Requested resource not found

I'm trying to batch update a bunch of existing records through Marketo's REST API. According to the documentation, the Import Lead function seems to be ideal for this.
In short, I'm getting the error "610 Resource Not Found" upon using the curl sample from the documentation. Here are some steps I've taken.
Fetching the auth_token is not a problem:
$ curl "https://<identity_path>/identity/oauth/token?
grant_type=client_credentials&client_id=<my_client_id>
&client_secret=<my_client_secret>"
Proving the token is valid, fetching a single lead isn't a problem as well:
# Fetch the record - outputs just fine
$ curl "https://<rest_path>/rest/v1/lead/1.json?access_token=<access_token>"
# output:
{
"requestId": "ab9d#12345abc45",
"result": [
{
"id": 1,
"updatedAt": "2014-09-18T13:00:00+0000",
"lastName": "Potter",
"email": "harry#hogwartz.co.uk",
"createdAt": "2014-09-18T12:00:00+0000",
"firstName": "Harry"
}
],
"success": true
}
Now here's the pain, when I try to upload a CSV file using the Import Lead function. Like so:
# "Import Lead" function
$ curl -i -F format=csv -F file=#test.csv -F access_token=<access_token>
"https://<rest_path>/rest/bulk/v1/leads.json"
# results in the following error
{
"requestId": "f2b6#14888a7385a",
"success": false,
"errors": [
{
"code": "610",
"message": "Requested resource not found"
}
]
}
The error codes documentation only states Requested resource not found, nothing else. So my question is: what is causing the 610 error code - and how can I fix it?
Further steps I've tried, with no success:
Placing the access_token as url parameter (e.g. appending '?access_token=xxx' to the url), with no effect.
Stripping down the CSV (yes, it's comma seperated) to a bare minimum (e.g. only fields 'id' and 'lastName')
Looked at the question Marketo API and Python, Post request failing
Verified that the CSV doesn't have some funky line endings
I have no idea if there are specific requirements for the CSV file, like column orders, though...
Any tips or suggestions?
Error code 610 can represent something akin to a '404' for urls under the REST endpoint, i.e. your rest_path. I'm guessing this is why you are getting that '404': Marketo's docs show REST paths as starting with '/rest', yet their rest endpoint ends with /rest, so if you follow their directions you get an url like, xxxx.mktorest.com/rest/rest/v1/lead/..., i.e. with '/rest' twice. This is not correct. Your url must have only one 'rest/'.
I went through the same trouble, just want to share some points that help resolve my problem.
Bulk API endpoints are not prefixed with ‘/rest’ like other endpoints.
Bulk Import uses the same permissions model as the Marketo REST API and does not require any additional special permissions in order to use, though specific permissions are required for each set of endpoints.
As #Ethan Herdrick suggested, the endpoints in the documentation are sometimes prefixed with an extra /rest, make sure to remove that.
If you're a beginner and need step-by-step instructions to set up permissions for Marketo REST API: Quick Start Guide for Marketo REST API