I have followed this tutorial step by step
https://github.com/actions-on-google/actionssdk-smart-home-nodejs
but when I add a lamp or something it gives me this error:
POST REQUEST_SYNC https://homegraph.googleapis.com/v1/devices:requestSync?key=AIzaSyAB1Nxi3kLQzA5VDr0MgXJ32GDWJ4TA710
POST payload: {"method":"POST","headers":{"Content-Type":"application/json"},"body":"{\"agentUserId\":\"1234\"}"}
POST /smart-home-api/reset-devices 200 59.124 ms - 2
request-sync response 404 Not Found
Any ideas?
Followed this
https://developers.google.com/actions/identity/oauth2-assertion-flow
try creating a credential
Create a OAuth 2.0 (webapplication option) client IDs under console.cloud.google.com/apis/credentials
Plugged in the client id which looks like this ............apps.googleusercontent.com under GSI Client ID under console.actions.google.com/project/ ->overview->account linking->configure client->Checked all the check boxes (Not sure if i should) ->GSI Client ID
I had the same issue. In my case the problem was:
in the SYNC request, it requires to have an "agentUserId" parameter and it was missing.
"requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
"payload": {
"agentUserId": "1836.15267389",
"devices": [{
https://developers.google.com/actions/smarthome/create-app
Make sure to send the same id when you send REQUEST_SYNC
Related
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 :)
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.
My goal is to create a number of ads using Facebook's Batch API : https://developers.facebook.com/docs/marketing-api/asyncrequests/v2.9
I am sending a POST request at this URL:
https://graph.facebook.com/v2.9/act_158365238/ads
I am sending 2 parameters as per the documentation:
1- access_token
2- batch
The JSON in the batch parameter looks like :
{
"method": "POST",
"relative_url": "v2.9\/act_158365238\/ads",
"attached_files": "test1",
"body": "creative={\"title\":\"Test title 1\",\"body\":\"Test body 1\",\"object_url\":\"https:\/\/apps.facebook.com\/testapp\/\", \"image_file\":\"test1.jpg\"}&targeting={\"countries\":[\"US\"]}&name=test1"
}
The Problem
When I send this request with POSTman or my PHP code, it throws the following error
{
"error": {
"message": "(#100) The parameter creative is required",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "Gj2sG7N8l1f"
}
}
However when I send the exact same request via Facebook's Graph API tool, it successfully creates the ads.
According to the API Documentation provided to create creatives you should be posting to the URL "v2.9/act_187687683/adcreatives"... The fragment of the batch that you are showing is used to create an Ad.
If, as you say, your intention is to create an AdCreative then you should be using something like the above, which differs in the body from what you are using:
{
"method": "POST",
"name": "create_creative",
"relative_url": "v2.9/act_187687683/adcreatives",
"attached_files": "test1",
"body": "title=Test title&body=Test body&link_url=http://www.test12345.com&image_file=test1.jpg"
}
In the other hand, if what you are creating is an add, then you should consider referencing the AdCreative by its ID as is done in the examples, hence in the case of a creative added in the same batch you could use the relative reference to the name:
creative={\"creative_id\":\"{result=create_creative:$.id}\"}
or if it is a creative already created you can reference it by the creative_id:
creative={\"creative_id\":\"123456\"}
I think the message is a red herring -- it's not seeing your body's creative field because the OAuth isn't properly set in your POSTman requests, so it isn't parsing the body or seeing the creative field.
If you don't know how to set OAuth in POSTman, here's a good tutorial:
https://docs.brightcove.com/en/video-cloud/concepts/postman/postman.html
I have a resource foo with the following structure:
GET /foo/1 returns:
{
"id": 1,
"server-key": "abcdef",
"status": "expired"
}
Status can either be active or expired. If it is expired I want the server to generate a new one.
Normally I'd issue PUT/PATCH foo/1 with the new key, but client doesn't know the key-generation algorithm.
I could also do a POST foo/1/server-key with no body, but that feels strange (I know this isn't very scientific reason though).
Any good ideas/patterns?
In case when you've got expired entity just make POST call on /foo without any parameters and server should return new entity (and HTTP response code should be 201):
{
"id": 2,
"server-key": "xyz",
"status": "active"
}
If some resourece is expired it is unconvinient to make it active again by PUT/PATCH request.
The approach I would adopt is to set a null value to server-key and let the server deal with it, but I do that because it's a consistent behavior in my APIs for the server to fill missing values with defaults.
Other than that, a simple POST to the URI as suggested in the other answer is adequate.
I think that you should use a PUT/PATCH method in your case to ask for generate a token if expired. Generally it's not really RESTful to put an action name within the resource path ;-)
I would see something like that:
Get the element: GET /foo/1
If the status is expired, ask for a new server key to be generated: POST /foo/1. In this case, this method will be used to execute an action to reinitialize the key on the server side
Using the method PUT corresponds to update the complete representation with a new one provided by the client. With the method PATCH, you will do a partial update of the representation.
Here is a link that could give you some hints about the way to design a Web API (RESTful service): https://templth.wordpress.com/2014/12/15/designing-a-web-api/.
Hope it helps you,
Thierry
I'm trying to use the REST API, from Postman REST client on Chrome.
Here's my screenshot:
I keep getting error 422: "The server understands the content type of the request entity and the syntax of the request entity is correct but was unable to process the contained instructions".
I'm using Activiti 5.16.3 on MacOS Maverick, with Java 1.8.
The process I tried to call is the one that comes with the demo of Activiti, Vacation Request.
The JSON payload in my request is:
{
"processDefinitionKey":"vacationRequest",
"variables":[
{"name": "employeeName", "value": "Raka","type":"string"},
{"name": "numberOfDays", "value": "5", "type":"integer"},
{"name": "vacationMotivation", "value": "", "type":"string"},
{"name": "startDate", "value": "01-01-2014 11:11", "type":"date"}
]
}
Oh, and I had to add a header "Content-Type" with its value set to "application/json" (otherwise I'd get error code 415: "The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method").
What am I missing?
Btw, I need to be able to demonstrate the use of the REST API through tools like Postman. So, no Java code. It's because another programmer (front-end) will interact directly with Activiti bpm.
Thanks in advance for your help. This is really critical.
**
Additional comments:
I didn't have issue with other REST methods that are GET (for example: listing process definitions, etc). Looks like I'm only having trouble with POST (and maybe PUT too).
Not much info on this on google: https://www.google.com/search?as_q=rest+422&as_epq=&as_oq=&as_eq=&as_nlo=&as_nhi=&lr=&cr=&as_qdr=all&as_sitesearch=http%3A%2F%2Fforums.activiti.org&as_occt=any&safe=images&as_filetype=&as_rights=&gws_rd=ssl
I've tried also this suggestion. Didn't work for me: http://forums.activiti.org/comment/23039#comment-23039
**
Best regards,
Raka
Solved now....
Looks like there should be no whitespace between the opening { and the rest of the document.
Here's my screenshot: