I want to post this JSON code and send it to https://localhost:44324/api/ocorrenciasapi:
{
"dispositivo":"dewdkij",
"latitude" : "39",
"longitude" : "-9",
"azimute": "43",
"fotografia": "lifhwee",
"estado":"ldhel"
}
I doing this on the Body-raw with JSON. However, everytime I send this request, it returns "There was an error in evaluating the Pre-request Script: SyntaxError: Unexpected token :". What should I do?
The same happens when I do the GET request.
NOTE: I'm using a API Controller with action, using Entity Framework.
Related
I'm trying to get to grips with the Places API and I am getting an invalid request when I enter the address_component as a field. The formatted_address works though I understand that should not be used if we want to parse it programatically.
Sample request:
https://maps.googleapis.com/maps/api/place/findplacefromtext/json?fields=address_components%2Cname%2Ctype&input=George%20Street&inputtype=textquery&key=MY_API_KEY
Response:
{
"candidates": [],
"error_message": "Error while parsing 'fields' parameter: Unsupported field name 'address_components'. ",
"status": "INVALID_REQUEST"
}
hey guys im having some wierd issue,
i get the error i stated in the title when i try to fetch something from an api,
when i check with postman with the same url i get a valid jason,
the request comes back with a status of 200 so its fine on that end.
howerver when i execute the following command the error occurs:
fetch('/api/bug',{mode:'no-cors'}).then(response => response.json())
.then(data => console.log(data));
the Json:
{
"_id" : "abc123",
"title" : "Cannot save ",
"description" : "problem ",
"severity" : 1,
"createdAt" : 154210735954,
"creator" : {"nickname" : "Nick"}
}
Edit:
After changing from Json To Text,
The fetch request returns the html of the page, and the postman request return a json, any reason for this?
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 set up a POST ressource in API Gateway which invokes a Lamdba function, fine.
In the "integration request", for text/plain Content-type, I defined the following mapping :
#set($messageStr = $util.urlEncode($input.body))
{
"message" : "$messageStr"
}
Problem is : whenever I POST data with JSON reserved characters, the integration request mapping thows
{"message": "Could not process payload"}
Example : blablabla will be correctly passed through to lambda, not {blablabla nor a:e ...
This seems like that method urlEncode expects JSON data.
Any idea how to pass whatever body as pure text ?
Thanks
I am trying to create a test case result using a REST client, but get this error:
"Errors": ["Cannot parse input stream due to I/O error as JSON document: Parse error: expected '{' but saw '\uFFFF' [ chars read = >>>\uFFFF<<< ]"]
I get the same error when the name of the object, testcaseresult is not specified in the request body. Here are the steps to create a test case result using a browser REST client:
a) Generate the authorize key using "GET" method and the following URL:
https://rally1.rallydev.com/slm/webservice/v2.0/security/authorize
This is the response that I get back, with the security token: "123abc..."
{"OperationResult": {"_rallyAPIMajor": "2", "_rallyAPIMinor": "0", "Errors": [], "Warnings": [], "SecurityToken": "abc123..."}}
b) Use "POST" method, and the following URL:
https://rally1.rallydev.com/slm/webservice/v2.0/testcaseresult/create?key=abc123...
notice the security token in the end.
c) here is an example of a request body:
{
"testcaseresult":
{
"Build":"1",
"Tester":"/user/777",
"Date":"2010-09-04T19:56:05.000Z",
"TestCase":"/testcase/1111",
"Verdict":"Pass"
}
}
Only the required fields and the fields you want to set need to be referenced. Notice the outer key/value pair
{
"testcaseresult":{}
}
The fields that point to a full object, like "Tester" (points to User object) and "TestCase" (points to a TestCase object that owns the result) have to be referenced by their ObjectIDs:
"Tester":"/user/777",
"TestCase":"/testcase/1111",