IBM Watson Assistant: How to solve web_action error "Internal error: Content-type can not be retrieved." - ibm-cloud

I'm trying to connect IBM Cloud Functions with a Watson Assistant dialog as web_action. So I have specified web_action as following in watson dialog json editor.
"actions": [
{
"name": "rajesh#heltha.co_dev/default/callKinvey",
"type": "web_action",
"parameters": {
},
"credentials": "$private.mycredential",
"result_variable": "context.my_input_returned"
}
]
Now, the issue is while testing assistant I'm getting following error
Internal error: Content-type can not be retrieved. (and there is 1 more error in the log)
Following is my function that is created on IBM-cloud and enabled for Web Action:
/**
*
* main() will be run when you invoke this action
*
* #param Cloud Functions actions accept a single parameter, which must be a JSON object.
*
* #return The output of this action, which must be a JSON object.
*
*/
function main(params) {
return { message: 'Hello World' };
}
CURL of my function is:
curl -u API-KEY -X POST https://us-south.functions.cloud.ibm.com/api/v1/namespaces/rajesh#heltha.co_dev/actions/callKinvey?blocking=true

The easiest way to solve this type of error is to append .json to your endpoint.

Related

Jfrog REST API Jenkins Groovy status code: 404, reason phrase: Not Found

I have a Groovy script which is run in the Jenkins script console. The script uses the JFrog Rest API to run some queries. One of which returns: status code: 404, reason phrase: Not Found
CURL:
$ curl -X GET -H "X-JFrog-Art-Api:APIKey" https://OU.jfrog.io/OU/api/storage/test-repository/docker-log-gen/1.12/manifest.json?properties
{
"properties" : { ... },
"uri" : "https://OU.jfrog.io/artifactory/api/storage/test-repository/docker-log-gen/1.12/manifest.json"
}
WGET
$ wget --header="X-JFrog-Art-Api:APIKey" https://OU.jfrog.io/OU/api/storage/test-repository/docker-log-gen/1.12/manifest.json?properties
--2020-01-14 13:12:16-- https://OU.jfrog.io/OU/api/storage/test-repository/docker-log-gen/1.12/manifest.json?properties
HTTP request sent, awaiting response... 200 OK
Jenkins Groovy
def restClient = new RESTClient('https://OU.jfrog.io')
restClient.headers['X-JFrog-Art-Api'] = 'APIKey'
println(restClient.get(path: '/OU/api/storage/test-repository/docker-log-gen/1.12/manifest.json?properties', requestContentType: 'text/plain') )
groovyx.net.http.HttpResponseException: status code: 404, reason phrase: Not Found
Other rest calls (api/docker) are made prior to this one in the script and return successfully. I am unable to identify a cause for this response, as shown the command-line calls return the expected JSON.
Please help.
The part after the first question mark is not the URI path component.
println(restClient.get(path: '/OU/api/storage/test-repository/docker-log-gen/1.12/manifest.json', query: ['properties': ''] , requestContentType: 'text/plain').data.text )
{
"properties" : { ... },
"uri" : "https://OU.jfrog.io/artifactory/api/storage/test-repository/docker-log-gen/1.12/manifest.json"
}

Spring Cloud Function and SQSEvent Triggered AWS Lambda Function

I'm unable to get a Spring-Cloud based AWS Lambda Function with an SQS Message trigger to work. I'm using the Spring Cloud Function AWS adapter version 2.0.1.RELEASE and attempting to deploy to the AWS EU-WEST-2 Region.
My SpringBootRequestHandler is defined as follows:
import org.springframework.cloud.function.adapter.aws.SpringBootRequestHandler;
import com.amazonaws.services.lambda.runtime.events.SQSEvent;
public class ReplicationHandler extends SpringBootRequestHandler<SQSEvent, String>{
}
My #Bean function looks as follows:
#Bean
public Function<SQSEvent, String> handleEvent() {
return value -> processEvent((SQSEvent)value);
}
I feed this with the following test event:
{
"Records": [
{
"messageId": "02a4e04b-a1d2-417a-b073-56123be35ac6",
"receiptHandle": "AQEB0fsSc76vU9Y6vQEz",
"body": "hello world",
"attributes": {
"ApproximateReceiveCount": "1",
"SentTimestamp": "1553860061037",
"SenderId": "AIDAIVEA3AGEU7NF6DRAG",
"ApproximateFirstReceiveTimestamp": "1553860061042"
},
"messageAttributes": {},
"md5OfBody": "a4d19d8b1019e01bb875eea6232bf2f1",
"eventSource": "aws:sqs",
"eventSourceARN": "arn:aws:sqs:eu-west-2:XXXXX:YYYYY",
"awsRegion": "eu-west-2"
}
]
}
When I run this , I get the following error:
{
"errorMessage": "reactor.core.publisher.FluxJust cannot be cast to com.amazonaws.services.lambda.runtime.events.SQSEvent",
"errorType": "java.lang.ClassCastException",
"stackTrace": [
"org.springframework.cloud.function.adapter.aws.SpringFunctionInitializer.apply(SpringFunctionInitializer.java:132)",
"org.springframework.cloud.function.adapter.aws.SpringBootRequestHandler.handleRequest(SpringBootRequestHandler.java:48)"
]
}
Anyone have any suggestions around what's going wrong here? Alternatively, if there are any working samples on the web for my exact scenario, that would be good as well.

resource type error while trying to use cloudformation

I tried to use the exact same example provided in the user guide mentioned below. It works from console but fails to create stack using client.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-athena-namedquery.html
I got an error while trying to execute the following:
{
"Resources": {
"AthenaNamedQuery": {
"Type": "AWS::Athena::NamedQuery",
"Properties": {
"Database": "swfnetadata",
"Description": "A query that selects all aggregated data",
"Name": "MostExpensiveWorkflow",
"QueryString": "SELECT workflowname, AVG(activitytaskstarted) AS AverageWorkflow FROM swfmetadata WHERE year='17' AND GROUP BY workflowname ORDER BY AverageWorkflow DESC LIMIT 10"
}
}
}
}
Is the "create-stack" parameter of cloudformation correct?
aws cloudformation create-stack --stack-name dnd --template-body file://final.json
Why am I getting a resource type error like this?
An error occurred (ValidationError) when calling the CreateStack operation: Template format error: Unrecognized resource types: [AWS::Athena::NamedQuery]
It worked when I updated my CLI version as suggested in the comment. This issue is now closed.

How to enable Javascript in Druid

I have been using Druid for the past week and wanted to enable javascript for some postAggregations.
I think I followed the outlined steps and updated the common.runtime.properties file in ../con f/druid/_common/ to include druid.javascript.enabled=true. I then stopped the current processes and re-ran the Quickstart procedures, but it still says that JavaScript is disabled:
{
"error" : "Unknown exception",
"errorMessage" : "Instantiation of [simple type, class io.druid.query.aggregation.post.JavaScriptPostAggregator] value failed: JavaScript is disabled. (through reference chain: java.util.ArrayList[0])",
"errorClass" : "com.fasterxml.jackson.databind.JsonMappingException",
"host" : null
}
I am currently running it in the 'Quickstart' configuration - single local machine. Any pointers? Thanks!
JavaScript Query For druid Aggregation. Save the file as .body and hit the curl request.
This is a sample query for Average value.
curl -X POST "http://localhost:8082/druid/v2/?pretty" \ -H
'content-type: application/json' -d #query.body
{
"queryType":"groupBy",
"dataSource":"whirldata",
"granularity":"all",
"dimensions":[],
"aggregations":[{"name":"rows","type":"count","fieldName":"rows"},
{"name":"TargetDOS","type":"doubleSum","fieldName":"Target DOS"}],"postAggregations":[
{
"type": "javascript",
"name": "Target DOS Average",
"fieldNames": ["TargetDOS", "rows"],
"function": "function(TargetDOS, rows) { return Math.abs(TargetDOS) / rows; }"
}], "intervals":[ "2006-01-01T00:00:00.000Z/2020-01-01T00:00:00.000Z" ]}
The part you are missing is likely that the quickstart reads configs from conf-quickstart rather than conf. So try editing conf-quickstart/druid/_common/common.runtime.properties.

SQL commands not available in Orientdb REST api

I am trying to POST commands to an Orientdb using the REST api. When I POST the following json:
{
"command" : "select * from system"
}
I get this response:
{
"errors": [
{
"reason": 500,
"content": "com.orientechnologies.orient.core.command.OCommandExecutorNotFoundException: Cannot find a command executor for the command request: sql.{\n\"command\" : \"select from system\"\n}",
"code": 500
}
]
}
However, the command works on the url
http://localhost:2480/command/demo1/sql/select * from system
but not in json.
It is possible from version 2.2 of OrientDb.
Look the documentation http://orientdb.com/docs/2.1/OrientDB-REST.html#command