when I use the sample PizzaShackAPI /order/{orderid} ,
if the parameters with character "*",
it Response "no response from server" as the same as my api;
How can this be fixed?
* is a reserved character, you must escape it as %2A because you aren't using it for the reserved purpose.
Related
I created an API Gateway which contains multiple query parameters.
When I try to invoke its URL on Postman it works very well:
'https://xxx.execute-api.eu-central-1.amazonaws.com/stage/getfile/test.csv/.'
But, when I simulate the same request on Lambda, I get a Missing Authentication Token error.
headers = { 'Content-Type': 'application/json'}
url= 'https://xxx.execute-api.eu-central-1.amazonaws.com/stage/getfile/test.csv/.'
r=requests.request("GET",url,headers=headers)
r.text
'{"message":"Missing Authentication Token"}'
Replacing the dot "." by another character in the URL makes the error disappear but I need to send a dot.
No solution is possible for this kind of problem. I had to replace "." with dot and manage it with my code.
I want to POST form data to api gateway which then sends it to lambda for processing. However, I get
{
"message": "Could not parse request body into json: Unexpected character (\'-\' (code 45))
in numeric value: expected digit (0-9) to follow minus sign, for valid numeric value\n
at [Source: (byte[])\"----------------------------086228525798973846089611\r\nContent-
Disposition: form-data; name=\"first_name\"\r\n\r\nfake\r\n---------------------------
-086228525798973846089611\r\nContent-Disposition: form-data;
name=\"last_name\"\r\n\r\nname\r\n---------------------------
-086228525798973846089611\r\nContent-Disposition: form-data;
name=\"email\"\r\n\r\nfakename1#something.com\r\n---------------------------
-086228525798973846089611\r\nContent-Disposition: form-data; name=\"mobile\"\r\n\r\n\r\n-
---------------------------086228525798973\"[truncated 752 bytes]; line: 1, column: 3]"
}
In the cloudwatch logs I can see lambda gives this error: Lambda invocation failed with status: 400. Can't see any errors in lambda logs just api gateway logs.
My api gateway POST method looks like this:
Edit:
Adding image of form I am trying to submit that the API isn't liking:
Any ideas how to POST through to lambda without api gateway transformations or other issue?
There is an API-Gateway - SNS integration.
Request body is application/json
Integration parameters:
Subject: method.request.body.Subject
Message: method.request.body.Message
TopicArn: 'arn:aws:sns:eu-west-1:*******:some-topic'
HTTP Headers: Content-Type='application/json'
Content handling : passthrough
Request body example:
{
"Subject": "Hello World",
"Message": "qwerty"
}
Now I'm struggling to make it pass new line characters (\n, \r\n, "\r\n" and many others combinations) inside the message to SNS. Value of 'Message' key is getting passed "as is".
Is there something I'm missing?
1.
I've been looking through the doc of wso2 apim. https://docs.wso2.com/display/AM210/apidocs/publisher/index.html#guide
And use the postman to send the request:
But I got 401 error response. As expected I should get the correct response payload like:
{
"callBackURL": "www.google.lk",
"jsonString":
"{
\"username\":\"admin\",
\"redirect_uris\":\"www.google.lk\",
\"tokenScope\":[Ljava.lang.String;#3a73796a,
\"client_name\":\"admin_rest_api_store\",
\"grant_types\":\"authorization_code password refresh_token iwa:ntlm
urn:ietf:params:oauth:grant-type:saml2-bearer client_credentialsimplicit\"
}",
"clientName": null,
"clientId": "HfEl1jJPdg5tbtrxhAwybN05QGoa",
"clientSecret": "l6c0aoLcWR3fwezHhc7XoGOht5Aa"
}
2.
I have used the same method to call another URL the response is 403.The URL is correct to enter the publisher.
How to solve it? Thank you.
Request Header
Request
Response Body
Response Cookies
Response Header
Publisher Log
Is your Authorization header valid?
"YWRtaW46YWRtaW4= " is for default admin:admin credentials.
You should base64 encode your actual username:password and set the value as a header.
I have a http endpoint name - HE. This 'HE' endpoint connected with Lambda function 'L'.
So HE-->L
On some situation 'L' return Exception in this format :
{
"errorMessage": "Name John Doe is invalid. Exception occurred...",
"errorType": "java.lang.Exception",
"stackTrace": [
"example.Hello.handler(Hello.java:9)",
"sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)",
"sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)",
"sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)",
"java.lang.reflect.Method.invoke(Method.java:497)"
]
}
And the same returned by the 'HE' as is.
How I can use the Integration Response(AWS API Gateway) at 'HE' so it should only display the following :
{
"errorMessage": "Name John Doe is invalid. Exception occurred..."
}
I'm not sure I understand your set-up correctly. I'm assuming that your API Gateway is calling your Lambda function and that your Lambda function is returning the string you gave as an error object. In that case...
Add a new method response to your method. Set HTTP status of the method response to the HTTP status code you want to return, maybe 400 for this case.
Add a new integration response to your method.
Set the "Lambda Error Regex" of the integration response to a regex which will uniquely identify the error. ".Name . is invalid.*" should work for this case.
Set the "Method response status" to the HTTP status of the method response (400 in my example).
Hit save. Expand the integration response. Expand "Body Mapping Templates". Click "Add mapping template". Set the Content-Type to "application/json" (or whatever content type you want). Click the check box.
In the mapping template editor box, add a mapping template like this...
#set($inputRoot = $input.path('$'))
{"errorMessage" : "$input.path('$.errorMessage')"}
If I misunderstood your set-up and your API Gateway is calling an HTTP endpoint, then the approach is similar, but the terminology of some of the terms changes.