I'm trying to work with the YoutubeLiveChat-API in Java.
I'm having trouble to insert a LiveChatMessage because it is always returning the errorcode 400:
{
"code" : 400,
"errors" : [ {
"domain" : "youtube.part",
"location" : "part",
"locationType" : "parameter",
"message" : "liveChatMessage",
"reason" : "unknownPart"
} ],
"message" : "liveChatMessage"
}
The error occurs at the following line:
youtube.liveChatMessages().insert("snippet,liveChatMessage",msg).execute();
I already know that the problem is insert(<String>,msg) but I don't know what to put int for String.
Thank you!
Related
I'm using Java API for calling the AppScript function on the spreadsheet
When I list deployments
List<Deployment> deployments = projects.deployments().list("XXX").execute().getDeployments();
I can see my deployments but the deployment.getFunctionSet() is NULL
So when I call
Operation op = service.scripts().run(
"XXX",
new ExecutionRequest().setDevMode(true).setFunction("exportJson")
).execute();
I get
{
"code" : 404,
"errors" : [ {
"domain" : "global",
"message" : "Requested entity was not found.",
"reason" : "notFound"
} ],
"message" : "Requested entity was not found.",
"status" : "NOT_FOUND"
}
The question - how to call function from the google app script? )
Ok so I am making API requests to retrieve certain things like movies, songs, or to ping the server. However all of these responses are contained within the same response JSON object that has varying fields depending on the response. Below are three examples.
ping
{
"response" : {
"status" : "ok",
"version" : "0.9.1"
}
}
getIndexes
{
"response" : {
"status" : "ok",
"version" : "0.9.1",
"indexes" : {
"index" : [ {
"name" : "A",
"movie" : [ {
"id" : "150",
"name" : "A Movie"
}, {
"id" : "2400",
"name" : "Another Movie"
} ]
}, {
"name" : "S",
"movie" : [ {
"id" : "439",
"name" : "Some Movie"
}, {
"id" : "209",
"name" : "Some Movie Part 2"
} ]
} ]
}
}
}
getRandomSongs
{
"response" : {
"status" : "ok"
"version" : "0.9.1"
"randomSongs" : {
"song": [ {
"id" : "72",
"parent" : "58",
"isDir" : false,
"title" : "Letter From Yokosuka",
"album" : "Metaphorical Music",
"artist" : "Nujabes",
"track" : 7,
"year" : 2003,
"genre" : "Hip-Hop",
"coverArt" : "58",
"size" : 20407325,
"contentType" : "audio/flac",
"suffix" : "flac",
"transcodedContentType" : "audio/mpeg",
"transcodedSuffix" : "mp3",
"duration" : 190,
"bitRate" : 858,
"path" : "Nujabes/Metaphorical Music/07 - Letter From Yokosuka.flac",
"isVideo" : false,
"created" : "2015-06-06T01:18:05.000Z",
"albumId" : "2",
"artistId" : "0",
"type" : "music"
}, {
"id" : "3135",
"parent" : "3109",
"isDir" : false,
"title" : "Forty One Mosquitoes Flying In Formation",
"album" : "Tame Impala",
"artist" : "Tame Impala",
"track" : 4,
"year" : 2008,
"genre" : "Rock",
"coverArt" : "3109",
"size" : 10359844,
"contentType" : "audio/mpeg",
"suffix" : "mp3",
"duration" : 258,
"bitRate" : 320,
"path" : "Tame Impala/Tame Impala/04 - Forty One Mosquitoes Flying In Formation.mp3",
"isVideo" : false,
"created" : "2015-06-29T21:50:16.000Z",
"albumId" : "101",
"artistId" : "30",
"type" : "music"
} ]
}
}
}
So basically my question is, how should I structure my model classes to use for parsing these responses? At the moment I have an abstract response object that only contains fields for the status and version. However, by using this approach I will need a response class that extends this abstract class for ever request I make (e.g. AbstractResponse, IndexesResponse, RandomSongsResponse). Also, some models with the same name may have different fields depending on the API request made. I would prefer to avoid making a model class for every possible scenario.
And as an extra note, I am using GSON for JSON serialization/deserialization and Retrofit to communicate with the API.
i am doin Amazon Stack Creation through Java Eclipse.
tis below line of code is throwing the error
csr.setTemplateURL("https://s3.amazonaws.com/cloudformation-templates-us-east- 1/AutoScalingMultiAZSample.template");
I am getting the error as :
Caught Exception: Parameters: [KeyName] must have values (Service: AmazonCloudFormation; Status Code: 400; Error Code: ValidationError; Request ID: 9363d711-3535-11e4-8cf2-913ef42879cb)
Reponse Status Code: 400
my json template url is
https://s3.amazonaws.com/cloudformation-templates-us-east-1/AutoScalingMultiAZSample.template
Please help on this to detect the exact source of the error.
Ok i tried to validate your json schema using online validator.
http://jsonlint.com/
I just copied your json schema and pasted there. It said invalid schema expecting { on line 1. Ok for sure i have to put opening and closing brackets and in between your schema. But again it gave error. Extra Bracket } on last line. So i had to remove it. And then json schema was validated. It means somewhere in your schema you are putting an extra closing bracket }.
I think the place where you are making mistake is:
"InstanceSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Enable SSH access and HTTP from the load balancer only",
"SecurityGroupIngress" : [ {
"IpProtocol" : "tcp",
"FromPort" : "22",
"ToPort" : "22",
"CidrIp" : { "Ref" : "SSHLocation"}
},
{
"IpProtocol" : "tcp",
"FromPort" : { "Ref" : "WebServerPort" },
"ToPort" : { "Ref" : "WebServerPort" },
"SourceSecurityGroupOwnerId" : {"Fn::GetAtt" : ["ElasticLoadBalancer", "SourceSecurityGroup.OwnerAlias"]},
"SourceSecurityGroupName" : {"Fn::GetAtt" : ["ElasticLoadBalancer", "SourceSecurityGroup.GroupName"]}
} ]
}
}//Extra Bracket i think so
},
"Outputs" : {
"URL" : {
"Description" : "The URL of the website",
"Value" : { "Fn::Join" : [ "", [ "http://", { "Fn::GetAtt" : [ "ElasticLoadBalancer", "DNSName" ]}]]}
}
}
}
I'm having an issue in STS creating a custom template. What I want is the ability to do token-based replacement within all files in the project. I've read this is possible with the "token" replacement, but cannot seem to get the wizard.json to let me accept multiple inputs. The "example" you see everywhere is replacing the top-level-package, which I've got to work great.
Anyone have any examples of doing multiple inputs in the wizard.json, or have any idea on what I'm doing wrong?
Here is what I have, which doesn't work:
{
"info" : {
"elements" : {
"element" : [
{
"name" : "mysystem",
"description" : "Please the name of your system (ex. marketing, hr, accounting, etc).",
"type" : "java.lang.String",
"page" : 0,
"required" : true,
"pattern" : "\\w+",
"replaceKind" : "token"
}
],
"element" : [
{
"name" : "myapp",
"description" : "Please the name of your application (ex. thisapplication, thatapplication, etc).",
"type" : "java.lang.String",
"page" : 0,
"required" : true,
"pattern" : "\\w+",
"replaceKind" : "token"
}
]
},
"projectName" : "projectName",
"pages" : {
"page" : [
{
"order" : 0,
"description" : "System Info"
}
]
}
}
}
The "myapp" picks up and does the translation, but the "mysystem" never even gets displayed for input (screen one is just the myapp text).
For those who run into the same problem, I have figured this out. Here is what I ended up with.
{
"info" : {
"elements" : {
"element" : [
{
"name" : "mysystem",
"description" : "Please the name of your system (ex. marketing, hr, accounting, etc).",
"type" : "java.lang.String",
"page" : 0,
"required" : true,
"pattern" : "\\w+",
"replaceKind" : "token"
},
{
"name" : "myapp",
"description" : "Please the name of your application (ex. thisapplication, thatapplication, etc).",
"type" : "java.lang.String",
"page" : 1,
"required" : true,
"pattern" : "\\w+",
"replaceKind" : "token"
}
]
},
"projectName" : "projectName",
"pages" : {
"page" : [
{
"order" : 0,
"description" : "System Info"
}
],
"page" : [
{
"order" : 1,
"description" : "System Info 2"
}
]
}
}
}
I am facing a strange problem here,
when I run below url from web browser or from java command line
http://maps.googleapis.com/maps/api/distancematrix/json?origins=416%2063,Sweden&destinations=424%2069,Stor%C3%A5s%20Industrigatan%2020,Angered,G%C3%B6teborg&sensor=false
I get below results.
{
"destination_addresses" : [ "StorĂ¥s Industrigata 20, 424 69
Angered, Sweden" ],
"origin_addresses" : [ "Gothenburg, Sweden" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "10.4 km",
"value" : 10388
},
"duration" : {
"text" : "15 mins",
"value" : 924
},
"status" : "OK"
}
]
}
],
"status" : "OK"
}
but when I run the same url from glassfish server I mean sending an
http request from
form submit I get below strange response
{ "destination_addresses" : [ "" ],
"origin_addresses" : [ "Gothenburg, Sweden" ],
"rows" : [
{
"elements" : [
{
"status" : "NOT_FOUND"
}
]
}
],
"status" : "OK"
}
please not destination_addresses is empty in this case and status in
NOT_FOUND.
Java code I used to get the response is
private String getResponse(String URL) throws Exception {
InputStream stream = new URL(URL).openStream();
byte[] array = new byte[stream.available()];
stream.read(array);
return new String(array);
}
please guide me to resolve this issue,
thanks....
Use https
unless google will not let your software to connect.
and
get a api key.
read this:
https://developers.google.com/maps/documentation/distance-matrix/start
https://maps.googleapis.com/maps/api/distancematrix/json?origins=416%2063,Sweden&destinations=424%2069,Stor%C3%A5s%20Industrigatan%2020,Angered,G%C3%B6teborg&sensor=false&key=YOUR_API_KEY
be sure to replace YOUR_API_KEY with your actual API key
I had a similar problem when using the Distance Matrix API in Java. Setting the language in my request seems to make it work:
DistanceMatrixElement distanceMatrixElement;
DistanceMatrix matrix;
try
{
matrix = distanceMatrixApiRequest
.origins(...)
.destinations(...)
.language("en")
.await();
}