I am getting an error while sending a json object to server. My json object is as follows:
{
"AppVersion": "2.0",
"connection": "3G",
"received": "2015-10-30",
"smsContent": "test string",
"msisdn": "923453334444"
}
When I send request, I am getting this error:
Malformed JSON: Unexpected 'c'
What is wrong with my json object? Can someone help here?
This may be due to the incorrect syntax of your code. I also got this error and corrected by eliminating unnecessary semicolons from my code.
Related
We would like to include the Integration/Source API JSON in the response, but when we attempt to include the Object, it does not encode properly.
"success": true,
"message": "Resource Call Made Successfully",
"data": {ip=127.0.0.1, ipv4=127.0.0.1, ipv6=0:0:0:0:0:0:0:0, asn=null, asn_name=null, country=US, useragent={family=Other...
As you can see, the strings lose their quotes; breaking the JSON. Here's the template;
#set($inputRoot = $input.path("$"))
{
"success": true,
"message": "Resource Call Made Successfully",
"data": $inputRoot
}
I've tried using $json.parse(), escaping, etc with no luck. Anyone familiar enough to give some direction on how to stringify this so I can include it in the response?
Use syntax like below,
"subject": "$util.escapeJavaScript($input.path('$.Attributes.subject.S')).replaceAll(\"\\\\'\",\"'\")"
It's an explanation in $util.escapeJavaScript() function
how to check only one value is accepted when the request is inserted? if both values are passes then send the error message using json. Either RegNumber or Pan should be accepted. i am very new to this
{
"email_id": "sample#example.com",
"RegNumber": "AM47",
"FromDate": 062020,
"ToDate": 062022,
"SchemaCode": 560043,
"PAN": "ABC44X"
}
I think you meant by get error in json response means app should return Json when it crashes, so to do, we must use middlewares and when you expect some error in response override that response error with your own custom json dict with error details.
Please I need some help regarding an error with Json. I am doing a homework test an trying to upload json to a database .. below is the Json
"{\"operation\":\"create\",\"tableName\":\"api\",\"payload\":{\"Item\":{ '"id":"334'","name":"'Lukas'", "occupation":"'Mjor'"' }}}"
But when I try to upload it I get an error:
{
"errorType": "SyntaxError",
"errorMessage": "Unexpected token i in JSON at position 83",
"trace": [
"SyntaxError: Unexpected token i in JSON at position 83",
" at JSON.parse (<anonymous>)",
" at Runtime.handleOnce (/var/runtime/Runtime.js:67:14)"
]
}
Please can someone help I read a bunch of articles still havent had a clue
I figured it out. I need to ident the same characters with .
"{\"operation\":\"create\",\"tableName\":\"apilambdadb\",\"payload\":{\"Item\":{\"id\":\"334\",\"name\":\"Mihael\", \"occupation\":\"Mjo\"}}}"
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}
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.