INVALID_REQUEST when sending a request with address_component - google-maps

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"
}

Related

How to determine if API accepts json in POST Requests - only seems to accept form-data

I have an API that I am posting to that accepts posts from me in Postman if the body is form-data and returns a 201. If, however, I format the body as JSON, I get back a 400 response indicating all the missing fields - e.g.
"errors": [
{
"code": "1000",
"message": "Missing parameter",
"origin": "first_name"
},...etc
I do not get, however, any indication that JSON is not accepted. Is there a way that I can determine if the API accepts posts with a JSON Body? If it does, it this the response I should be getting?

Error using Postman when trying to POST and GET

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.

Twilio HTTP response: Not parsing XML/JSON

Using Twilio Studio, my HTTP widget obtains the following JSON from (external) endpoint:
{
"response": {
"say": "1 address found",
"data": [
"10707 Ewing Drive Kansas City Kansas"
]
}
}
However, I am able to access {{widgets.http_address_schedule.body}} but not {{widgets.http_address_schedule.parsed.say}}. Twilio documentation indicates this is possible if my response is JSON.
From documentation at: https://www.twilio.com/docs/studio/user-guide#rest-api
Json: If your function returns valid Json, you should be able to
access it via widgets.MY_WIDGET_NAME.parsed
For example, if you return {"message": "Hi", "person": {"name": "Bob",
"age": 40}}, you can reference that in subsequent widgets as:
widgets.MY_WIDGET_NAME.parsed.message
widgets.MY_WIDGET_NAME.parsed.person.name
widgets.MY_WIDGET_NAME.parsed.person.age
What is the expected way to send data to be parsed by Twilio?
After reviewing Twilio Studio logs, I was able to identify PHP error output embedded in the JSON response. Once the error was resolved Twilio was able to successfully parse response and provide data in parsed key in {{widgets.http_address_schedule.parsed.response.say}}

PUT API with path parameter and request body

I have a PUT API Gateway endpoint which should be used to update a DynamoDB entry.
The id for that DynamoDB entry is given as the path parameter.
I have the following mapping template:
"application/json": {
"id": "$input.params('id')",
"title": "$input.json('$.title')"
}
The id is returned as expected.
If I submit this request body
{
"title": "Hello world"
}
I get the error Could not parse request body into json: Unexpected character (\'t\'
Here's the overview of my AWS management console:
what am I missing?
So I just found the solution:
"title": "$input.json('$.title')"
should be
"title": $input.json('$.title') (without the double quotes).
Source: http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html#input-variable-reference

Rally JSON I/O error creating a test case result

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",