AWS API Gateway Model : Invalid model schema specified - json

I am getting error while creating Model in aws api gateway, Json is in correct format and still it says validation error. Please anyone? where I went wrong?
Error message "Invalid model specified: Validation Result: warnings : [], errors : [Invalid model schema specified]"
Json Schema i am trying to use is:
{
"action":"createOrUpdate",
"Content-Type":"application/json",
"accept":"application/json",
"input":[
{
"utm_CustomObj":"19UYA31581L000000",
"leadId":"1071319"
}
]
}
Error screen shot

You don't seem to be actually defining a schema for your data. Please refer to the API gateway documentation for some examples of defining a model with JSON schema.

It probably should follow Open API json format, like Api Gateway "Error" model.
Error model
{
"$schema":"http://json-schema.org/draft-04/schema#",
"title":"Error Schema",
"type":"object",
"properties":{
"message":{
"type":"string"
}
}
}
Find out more at: Swagger Docs

Apache Velocity Template Language is the language of the model. If you are creating a model this is the language you are using, not JSON .

Related

Translate revit model to svf from bucket id

Im trying to translate a revit model to svf using this endpoint https://developer.api.autodesk.com/modelderivative/v2/designdata/job
According to the docs this endpoint needs at lest these two attributes to work:
urn
formats
First I got the objectId from the desired object inside my bucket :
"objectId":"urn:adsk.objects:os.object:gkwz1o52jxgqnqkhay5dlgcg7e2xglal_tutorial_bucket/rst_basic_sample_project.rvt"
and then I used https://www.base64encode.org/ to encode this string and get my urn, following the advice from this question how to get the urn of the bucket file. The result urn was this:
dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6Z2t3ejFvNTJqeGdxbnFraGF5NWRsZ2NnN2UyeGdsYWxfdHV0b3JpYWxfYnVja2V0L3JzdF9iYXNpY19zYW1wbGVfcHJvamVjdC5ydnQ=
Finally I got the format from the examples and I removed the = from the urn string.
My final body data is this:
{
"input": {
"urn": "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6Z2t3ejFvNTJqeGdxbnFraGF5NWRsZ2NnN2UyeGdsYWxfdHV0b3JpYWxfYnVja2V0L3JzdF9iYXNpY19zYW1wbGVfcHJvamVjdC5ydnQ"
},
"output": {
"formats": [
{
"type": "svf",
"views": ["2d", "3d"]
}
]
}
}
But im getting this message:
I thought that was I getting the right object, and getting the urn, but still don't know what I'm doing wrong.
The endpoint URL, payload, and the base64-encoded object ID all seem to be fine. Try a couple of things:
Make sure that you that you're using POST method when calling the endpoint
Make sure that you're using the same Forge credentials (client ID and secret) you used when uploading the Revit model to the bucket
Try other ways of calling the endpoint, for example, using Postman or the VSCode extension

Getting an error while sending a json payload in quartz scheduler

I'm trying to send a json payload in quartz scheduler. I have the header set to Content-type:application/json, but for some reason my json string is throwing an error: Uncaught error, unexpected token in json.
The original json that I'm sending to a graphql service looks like this:
{
GetAllAuthors{
id
name
}
}
But to make it work in quartz, I need to mimic a rest API call, which is why I tried using the following:
{ "query":{{""{\nGetAllAuthors {\nid\nname\n}\n\n}""}} }
The above is also giving me the "Uncaught error, unexpected token in json" error. Is there something that I'm missing or overlooking?
PS: I tried using an online json formatter and when I try to validate the above json, I get the following error:
Error: Parse error on line 2:
{ "query": { { "" {\ nGetA
--------------^
Expecting 'STRING', '}', got '{'
That's not valid Json. This is how it might look if it were:
{
"GetAllAuthors": [
"id",
"name"
]
}
but I suspect you're trying for something like this:
{
"GetAllAuthors": {
"id": 123,
"name": "James Brown"
}
}
Play here until you get it right: https://jsonlint.com/
Edit: I've not worked with GraphQL, but this page shows how a (non JSON) GraphQL query might be transferred over Http by POSTing JSON or GETting using querystrings: https://graphql.org/learn/serving-over-http/
I figured this out by testing through Mozilla's network tab - the correct format is:
{"query":"{\n GetAllAuthors{\n id\n name\n}\n}\n","variables":null, "operationName":null}

Is there an alternative to "type": "undefined" in JSON?

I'm working with Amazon API Gateway. I am creating a model for an REST API. The model gets hung up on:
"tiers": {
"type": "array",
"items": {
"type": "undefined"
}
}
The API data model uses JSON schema draft 4.
The error returned is:
Invalid model specified: Validation Result: warnings : [], errors :
[Invalid model schema specified]
Anyone run into this before?
Things I've tried:
Removing this property = script creates model
Changing "Undefined" to "null" = script creates model
The "null" seems like the right option but, I've not been able to back it up. Some guidance and/or clarification would be greatly appreciated.
Thanks,
Todd
You don't seem to be actually defining a schema for your data, refer to the API gateway docs to re-define your model.
undefined is not a valid json value, even though it is valid in javascript. From the official json standard (ECMA-404, Section 5):
A JSON value can be an object, array, number, string, true, false, or
null.
For json, use null instead of undefined: { "something": null }
Using null instead of undefined is definitely not ideal, but it's a standard you can count on when consuming third-party services.

stackdriver: attempt to annotate instance returns 'CustomMetric data payloads must either be a list or a dict'

I am sending to stackdriver the following json trying to annotate an aws instance:
{ "message": "instance impaired", "annotated_by": "Ops User", "level": "WARN", "instance_id": "i-xxxxxxxxxxxxxxxx", "event_epoch": 1484903331 }
It returns the error:
HTTP 400: Bad Request (CustomMetric data payloads must either be a list or a dict. You sent: <type 'NoneType'>)
What is wrong with my json? What does a "dict" mean in stackdriver language. I couldn't find anything in the web about that error.
It turned out I was using a wrong endpoint. Now it is working as expected.

Error registering Weather Forcast data model (NGSI v2)

I am trying to register weather forcast on ContextBroker V1.5.0 but getting below error :-
400 Bad Request
{
"error": "BadRequest",
"description": "attribute must be a JSON object, unless keyValues option is used"
}
Request:
POST http://[ContextBroker IP]:1026/v2/entities
Request header :
Content-Type:application/json
Here is the payload
{
"feelsLikeTemperature":31.8,
"dayMinimum":{"feelsLikeTemperature":31.8,"temperature":0.0,"relativeHumidity":31.0},
"temperature":0.0,
"dateCreated":"2016-12-01T12:05:00+05:30",
"type":"WeatherForecast",
"address":{"addressCountry":"IN","postalCode":"452001","addressLocality":"Indore"},
"windSpeed":3.7,
"validity":{"to":"2016-12-01T06:44:37Z","from":"2016-12-01T06:44:37Z"},
"source":"http://dataservice.accuweather.com/",
"precipitationProbability":0,
"dayMaximum":{"feelsLikeTemperature":31.8,"temperature":0.0,"relativeHumidity":31.0},
"weatherType":"Partly sunny",
"windDirection":"ENE",
"id":"452001_IN_YYYY-12-DD ",
"relativeHumidity":31.0
}
I verified with FIWARE data models on http://fiware-datamodels.readthedocs.io/en/latest/Weather/WeatherForecast/doc/spec/index.html but it does not seem to be working. Does anyone know solution to this problem?
you are using the 'keyValues' representation so you need to do your POST with ?options=keyValues
by the way the WeatherForecast data model just landed updated with some adjustments to comply with GSMA specification.
http://fiware-datamodels.readthedocs.io/en/latest/Weather/WeatherForecast/doc/spec/index.html
thanks!