Invalid argument in Google Actions regarding noInputPrompts - json

I am getting the following error in the Google Actions console and can't seem to work out where I'm going wrong. I've tried to use this link for guidance. If remove the "noInputPrompts" section then the response works as expected.Any ideas please?:
API Version 2: Failed to parse JSON response string with 'INVALID_ARGUMENT' error: "(expected_inputs[0].input_prompt.no_input_prompts[0]) simpleResponse: Cannot find field." HTTP Status Code: 200.
My response looks like this:
"expectedInputs": [
{
"possibleIntents": [
{
"intent": "actions.intent.TEXT"
}
],
"inputPrompt": {
"richInitialPrompt": {
"items": [
{
"simpleResponse": {
"textToSpeech": "test",
"displayText": "test"
}
}
]
},
"noInputPrompts": [
{
"simpleResponse": {
"textToSpeech": "Test",
"displayText": "Test"
}
}
]
}
}

Related

How to change response data extract in POSTMAN

as in this example, I get the data from Starwar's GraphQL: https://swapi-graphql.netlify.app/.netlify/functions/index
Body Request:
query {
allFilms {
films {
title
}
}
}
Response data:
{
"data": {
"allFilms": {
"films": [
{
"title": "A New Hope"
},
{
"title": "The Empire Strikes Back"
},
{
"title": "Return of the Jedi"
},
{
"title": "The Phantom Menace"
},
{
"title": "Attack of the Clones"
},
{
"title": "Revenge of the Sith"
}
]
}
}
}
However, I want to get the responding data as an array of "films" like this:
[
{
"title": "A New Hope"
},
{
"title": "The Empire Strikes Back"
},
{
"title": "Return of the Jedi"
},
{
"title": "The Phantom Menace"
},
{
"title": "Attack of the Clones"
},
{
"title": "Revenge of the Sith"
}
]
So how can I do that? (if I'm not wrong, it's related to Pre-request Script)
You won't be able to change the format of the response, but you can process the result so it provides exactly what you want. I created this request on Postman so you can see how I've done it.
You need to transform the response when you fetch it, in postman you would do so in the Tests tab (i.e. post-response script vs pre-request):
// Getting the response data into a variable response
const response = pm.response.json();
// Converting the original response to the format you want
const filmArray = response.data.allFilms.films
// Logging it to the console so you can verify the results
console.log(filmArray)
This is the result of that console.log on postman:

GraphQL Query returns null objects both in GraphiQL and App from JSON data source

I'm trying to get my mocked JSON data via GraphQL in Gatsby. The response shows the correct data, but also two null objects as well. Why is it happening?
I'm using the gatsby-transformer.json plugin to query my data and gatsby-source-filesystem to point the transformer to my json files.
categories.json
the mock file I'm trying to get to work :)
{
"categories": [
{
"title": "DEZERTY",
"path": "/dezerty",
"categoryItems": [
{
"categoryName": "CUKRIKY",
"image": "../../../../static/img/dessertcategories/cukriky.jpg"
},
{
"categoryName": "NAHODNE",
"image": "../../../../static/img/dessertcategories/nahodne.jpg"
},
]
},
{
"title": "CANDY BAR",
"path": "/candy-bar",
"categoryItems": [
{
"categoryName": "CHEESECAKY",
"image": "../../../../static/img/dessertcategories/cheesecaky.jpg"
},
{
"categoryName": "BEZLEPKOVÉ TORTY",
"image": "../../../../static/img/dessertcategories/bezlepkove-torty.jpg"
},
]
}
]
}
GraphQL query in GraphiQL
query Collections {
allMockJson {
edges {
node {
categories {
categoryItems {
categoryName
image
}
title
path
}
}
}
}
}
And the response GraphiQL gives me
{
"data": {
"allMockJson": {
"edges": [
{
"node": {
"categories": null
}
},
{
"node": {
"categories": null
}
},
{
"node": {
"categories": [
{
"categoryItems": [
{
"categoryName": "CHEESECAKY",
"image": "../../../../static/img/dessertcategories/cheesecaky.jpg"
},
{
"categoryName": "BEZLEPKOVÉ TORTY",
"image": "../../../../static/img/dessertcategories/bezlepkove-torty.jpg"
}
],
"title": "DEZERTY",
"path": "/dezerty"
},
{
"categoryItems": [
{
"categoryName": "CUKRIKY",
"image": "../../../../static/img/dessertcategories/CUKRIKY.jpg"
},
{
"categoryName": "NAHODNE",
"image": "../../../../static/img/dessertcategories/NAHODNE.jpg"
}
],
"title": "CANDY BAR",
"path": "/candy-bar"
}
]
}
}
]
}
}
}
I expected only to get the DEZERTY and CANDY BAR sections. Why are there null categories and how do I fix it?
Thanks in advance
Your JSON contains syntax errors in the objects DEZERTY and CANDY BAR. It silently fails without telling you. Try this json linter.
Error: Parse error on line 12: },
Error: Parse error on line 25: },
Try again. Your query should work now.
You should look into an IDE that highlights these types of errors and saves you time and frustration.

parse JSON coming from a REST service in a React Native app

I need help to parse the following JSON coming from a REST service.
I want to read into an array and further each item I have to display on a mobile screen.
[
{
"Login":
{
"Status": "Success",
"nm_vw": {
"EMPLID": "88888",
"NAME": "sample test"
}
}
}
]
You can access data like:
let data=[
{
"Login":
{
"Status": "Success",
"nm_vw": {
"EMPLID": "88888",
"NAME": "sample test"
}
}
}
];
to access status use:
console.log(data[0]['Login']['Status']);
to read emplid:
console.log(data[0]['Login']['nm_vw']['EMPLID']);

Forge ModelDerivativeAPI: can't convert to obj format

I'm trying to convert .nwc file uploaded on my A360 account with ModelDerivativeAPI with this method. While converting to svf and some other formats works for me perfectly I have troubles with converting to obj format. I keep getting the following 400 error:
{
"diagnostic": "Failed to trigger translation for this file." }
Here is the body of my POST request:
{
"input": {
"urn": "dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLjJFZWM1RzZsU1NXMXNnVmFUSW93Zmc_dmVyc2lvbj0x"
},
"output": {
"formats": [
{
"type": "obj"
}
]
}
}
What am I doing wrong?
Try to add the advanced field as follow:
{
"input": {
"urn": "dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLjJFZWM1RzZsU1NXMXNnVmFUSW93Zmc_dmVyc2lvbj0x"
},
"output": {
"formats": [
{
"type": "obj",
"advanced": {
"objectIds": [-1], // -1 means all nodes, otherwise specify an array of valid dbIds
"modelGuid": "ab2fb5b0-9101-0d3e-28c9-e61f9f0c15c5" // Get this one from the GET :urn/metadata call - https://developer.autodesk.com/en/docs/model-derivative/v2/reference/http/urn-metadata-GET/
}
}
]
}
}
You can use my sample https://oss.autodesk.io which exposes a UI to help you test and format the payloads:
Hope that helps

Use Apps Script URLFetchApp to access Google Datastore Data

I want to experiment with Google Datastore via Apps Script because I have a current solution based on Google sheets that runs into timeout issues inherent in constantly transacting with Drive files. I've created a test project in Google cloud with a service account and enabled library MZx5DzNPsYjVyZaR67xXJQai_d-phDA33
(cGoa) to handle the Oauth2 work. I followed the guide to start it up here and got all the pertinent confirmation that it works with my token (and that removing the token throws an 'authentication failed prompt').
Now I want to start with a basic query to display the one entity I already put in. I can use the API Explorer here and run this query body:
{
"query": {}
}
and get this result:
{
"batch": {
"entityResultType": "FULL",
"entityResults": [
{
"entity": {
"key": {
"partitionId": {
"projectId": "project-id-5200707333336492774"
},
"path": [
{
"kind": "Transaction",
"id": "5629499534213120"
}
]
},
"properties": {
"CommentIn": {
"stringValue": "My First Test Transaction"
},
"Status": {
"stringValue": "Closed"
},
"auditStatus": {
"stringValue": "Logged"
},
"User": {
"stringValue": "John Doe"
},
"Start": {
"timestampValue": "2017-08-17T18:07:04.681Z"
},
"CommentOut": {
"stringValue": "Done for today!"
},
"End": {
"timestampValue": "2017-08-17T20:07:38.058Z"
},
"Period": {
"stringValue": "08/16/2017-08/31/2017"
}
}
},
"cursor": "CkISPGogc35whh9qZWN0LWlkLTUyMDA3MDcwODA1MDY0OTI3NzRyGAsSC1RyYW5zYWN0aW9uGICAgICAgIAKDBgAIAA=",
"version": "1503004124243000"
}
],
"endCursor": "CkISPGogc35wcm9qZWN0LWlkLTUyMDAxxDcwODA1MDY0OTI3NzRyGAsSC1RyYW5zYWN0aW9uGICAgICAgIAKDBgAIAA=",
"moreResults": "NO_MORE_RESULTS"
}
}
I try to do the same thing with this code:
function doGet(e)
{
var goa = cGoa.GoaApp.createGoa('Oauth2-Service-Account',
PropertiesService.getScriptProperties()).execute(e);
if(goa.hasToken()) {var token = goa.getToken();}
var payload = {"query":{}}
;
var result = UrlFetchApp.fetch('https://datastore.googleapis.com/v1/projects/project-id-5200707333336492774:runQuery',
{
method: "POST",
headers: {authorization: "Bearer " + goa.getToken()},
muteHttpExceptions : true,
payload: payload
});
Logger.log(result.getBlob().getDataAsString());
}
and get this error in the logger:
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"query\": Cannot bind query parameter. 'query' is a message type. Parameters can only be bound to primitive types.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"description": "Invalid JSON payload received. Unknown name \"query\": Cannot bind query parameter. 'query' is a message type. Parameters can only be bound to primitive types."
}
]
}
]
}
}
If I try to use another word such as 'resource' or 'GqlQuery', I get this error:
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"GqlQuery\": Cannot bind query parameter. Field 'GqlQuery' could not be found in request message.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"description": "Invalid JSON payload received. Unknown name \"GqlQuery\": Cannot bind query parameter. Field 'GqlQuery' could not be found in request message."
}
]
}
]
}
}
I can't tell from the API Documentation what my syntax is supposed to be. Can anyone tell me how to compile a functional request body from Apps Script to Datastore?
You need to set the contentType of your payload as well as stringify your JSON payload as follows:
var result = UrlFetchApp.fetch(
'https://datastore.googleapis.com/v1/projects/project-id-5200707333336492774:runQuery',
{
'method':'post',
'contentType':'application/json',
'headers': {authorization: "Bearer " + goa.getToken()},
'payload':JSON.stringify(payload)
}
);