Data Fusion alert HTTP Callback is failing with error code 411 - google-cloud-platform

In data fusion Alert I want to invoke an API using(HTTP callback) running in Cloud Run after successful pipeline execution.
I am getting response code 411
It is a POST request call. I am not sending any request body so I have updated Content-Length:0 in request header. still getting the response code 411.
I want to know the steps to be followed to make a successful http post call

Related

AWS X Ray logging HTTP 404 response as 200 instead

I'm setting up AWS X-Ray integration for my lambda service in Python, but I've encountered a strange issue.
I make an external HTTP call with the built in Python requests library, and my logs show that the status code is 404. Here's a snippet:
...
response = get_request(url, headers, params)
print(f"stat = {response.status_code}") # logs as 404
...
When I check AWS X-Ray, I can see the error rate is 100%:
But when I click on traces, the response code then becomes 200.
Why is there a discrepancy between the response codes?
From the documentation here, I should only need to add patch_all() method in order to trace my requests, which I've already done, so why is it I am still seeing 200 response.

Is there a workaround for Postman's bug when content is returned with a 204?

Using Postman, when I make a PUT request to an endpoint which returns a 204 with content, Postman is unable to parse the response, and my collection runner stops that iteration, indicating that an error has occurred.
When run outside of the runner, Postman displays the following:
Other people have also had this problem
Unfortunately I cannot fix the non-standard endpoint. Is there a workaround that will let Postman continue without throwing an error, especially when using the collection runner?
The 204 (204 NO CONTENT) response from the server means that the server processed your request successfully and a response is not needed.
More here: https://httpstatuses.com/204
Actually as much as I know, if the server is sending a 204 with a payload response, the endpoint is not developed as it should.
This would be the main reason Postman is not showing a response payload. You will only be able to read response headers.
So if you send a PUT request, and only receive headers, it means everything is ok. If you spect data the server should be responding with a 200 code.
Now, said this, if postman is telling you that “it could not get any response” it means basically the server is not responding any thing. Now try to increase the timeout in the postman settings. It’s very probable that the server is taking to much time. Check outside the runner how much time it’s taking to response.
I hope this helps you.

AWS API Gateway Multiple 2XX Responses

We have an API endpoint we are building through API Gateway that can have two possible successful responses: 200 OK if all of the requested data is returned, and a 206 Partial Content if the data is paginated and additional requests are required to fetch all the data.
I found at https://aws.amazon.com/blogs/compute/amazon-api-gateway-mapping-improvements/ that Amazon now allows multiple 2XX responses to be defined, but I cannot attribute both responses to a success in the Integration Response configuration. Right now we have 200 set as the default, but it appears as if we have to specify a Lambda Error Regex for the 206 mapping.
Does this basically mean that I have to fail the 206 with an error message and then use the regex to determine if that message is being sent, and then basically just treat it like a success? Or how can I properly return either a 200 or a 206 as a successful response?
The endpoint that AWS will hit on our server will properly return a 200 or a 206, but when AWS responds to the client it is currently only sending a 200.
Does this basically mean that I have to fail the 206 with an error
message and then use the regex to determine if that message is being
sent, and then basically just treat it like a success?
Yes, that is correct. Quirky, wrong, but it works.
The API gateway doesnt provide sending multiple success 2xx response. Below are some options
Make your lambda or backend application fail and return some json response. Create a regex in integration response and map the response to a particular error code. The matching of regex is done on errorMessage field which can be only get once you throw error from lambda.
Utilise reponse overriding. You can create a default mapping which matches all or some responses and then in the mapping template you can override the status code to whatever you want to send back.
Eg:-
Lambda returns
def handler(event, context):
x = {
"message": "partial"
}
return x
API gateway integration response
Lambda error regex: -
Method response status: 200
Default mapping: Yes
Mapping template:
#set($inputRoot = $input.path('$'))
$input.json("$")
#if($inputRoot.toString().contains("partial"))
#set($context.responseOverride.status = 206)
#end

How do I generate a specific HTTP response code using a POSTMAN test?

I am testing an API with postman using simple GET, POST, and PUT requests. I have only 2 variables in the header each time (content-type and user) and am using a simple raw json script in the body when I run POST. Currently I only get 2-3 HTTP status response codes, 200 OK for success and 400 (bad request if I don't have the body info) and 404 if the URL is not correct. But I need to test multiple HTTP requests (201 Created, 202 Accepted, etc..) and I can't figure out how to trigger a specific response code. Using 201 as an example, I am using a test script like such: tests["Status code is 201 Created"] = responseCode.code === 201; Other than that, what do I need to do to trigger that specific response code? The HTTP/Semantics and Content doc says, the following but it doesn't make sense to me;
HTTP/1.1 Semantics and Content
The 201 (Created) status code indicates that the request has been
fulfilled and has resulted in one or more new resources being
created. The primary resource created by the request is identified by either a Location header field in the response or, if no Location
field is received, by the effective request URI.
The 201 response payload typically describes and links to the
resource(s) created. See Section 7.2 for a discussion of the meaning
and purpose of validator header fields, such as ETag and
Last-Modified, in a 201 response.
describe('response', function() {
it('status must be OK', function() {
response.should.have.status(200);
response.should.not.be.empty;
});
});
You can chage this line ex. with: response.should.have.status(201);
I hope help you with the examples.

Call an async fire and forget SOAP webservice with JMeter

I'm calling an async fire-and-forget SOAP webservice using jmeter and showing the results in a table.
If i use an WebService(SOAP) Request sampler, it will log the call result as an warning, even if the status code is 200, cause the ws respond with an empty message.
With a SOAP/XML-RPC Request, the log table show te request as concluded.
It's possible to tell to an WebService(SOAP) Request to understand a empty response as a valid response ?
Thanks.
In code of WebService Soap sampler it is said that:
// It is not possible to access the actual HTTP response code, so we assume no data means failure
Code excerpt:
// It is not possible to access the actual HTTP response code, so we assume no data means failure
if (length > 0){
result.setSuccessful(true);
result.setResponseCodeOK();
result.setResponseMessageOK();
} else {
result.setSuccessful(false);
result.setResponseCode("999");
result.setResponseMessage("Empty response");
}
So you don't have a solution with this sampler.
Another solution is to use HTTP Sampler with Raw Post Body and test only response code with assertion.
I opened a Bugzilla Enhancement request:
https://issues.apache.org/bugzilla/show_bug.cgi?id=53978