Request method not recognized after promisification - node.js

I built an API using AWS API Gateway and Lambda, now I am writing end to end tests, I am using Promise from bluebird and request, so I promisified request like this:
Promise.promisifyAll(require('request'));
Promise.promisifyAll(request);
Now when I make requests (POST, PUT, GET), using request.methodAsync, the method is not recognized by the API Gateway !
I launched Jasmine with :
NODE_DEBUG=request jasmine
I can see the method = 'POST' or whatever, but the API still not recognize the method of the requests I am making with the promisified request ! any one run into this situation ?

Hi I'm from the Api Gateway team. As long as the request is sent to a valid resource path / HTTP method pair on a deployed API, Api Gateway will accept it. Please note you'll need to put the stage name as the first path part in the URI (see example in the Api Gateway console on the Stages page).
If you're invoking the right API resource, the issue sounds like a client-side bug.
Jack

Related

How do I test a next js api route which uses next-connect?

I followed this article here, to try testing a simple api route in Next.js.
This article uses node-mocks-http to mock req and res objects.
It works with normal next api (which doesn't use next-connect, eg. described in the article above), but when I try to use it with an api which uses next-connect, jest throws a timeout error.
Error: Exceeded timeout of 5000ms for a test.
Use jest.setTimeout(newTimeout) to increase
Looks like the api doesn't respond, but it works when I try it normally through the browser.

How to send custom http response code back from spring cloud functions?

I was using Spring Cloud Functions with azure...but could not figure out how using Spring cloud function I can send a custom HTTP code back in response.... as we can do in ResponseEntityAs of now I do not see a way of doing that. let's say after validation I want to throw a 400 BAD REQUEST error in the response or add some specific parameter in the response header, how do I do that.

Azure Api Managment: Function app seems not to be invoked?

I followed this link provided by Microsoft Azure to import a Function App within Api Management. I achieved to import my function and to test it by sending a Http Request (method GET), I got a Http Response with a code 200 OK. However, there is no content (content-length: 0) but it has to return a json string in the body. It seems that the function app is not invoked. This is something I checked when I test individually my function app.
Do you have an idea why there is no content ?
Thanks

Webrtc connectivity test - unknown API key

When we try to run the UDP and Bandwidth tests from the given sample code, it tries to hit a Google API service URL (using ajax call) which looks like "https://networktraversal.googleapis.com/v1alpha/iceconfig?key=".
This service URL needs to be appended with an API_KEY before making an ajax call.
When I tried to run this example https://test.webrtc.org/
It is appending API_KEY to the Base_URL and making an ajax call (POST call) to get some data.
The tests are initiated based on the response data.
Base_URL: "https://networktraversal.googleapis.com/v1alpha/iceconfig?key="
API_KEY: "AIzaSyDX4ctY_VWUm7lDdO6i_-bx7J-CDkxS16I"
Service URL looks like this: "https://networktraversal.googleapis.com/v1alpha/iceconfig?key=AIzaSyDX4ctY_VWUm7lDdO6i_-bx7J-CDkxS16I"
This service gives the response.
All the tests like UDP, Bandwith etc are performed based on the "response.iceServers" Array.
When I tried to hit this service using the same API_KEY from the example, it is throwing an error "Invalid API_KEY from the request URL." So here to access this data we need to have an API_KEY.
Can someone please tell me what API_KEY is this and which one should I use??
Regards.

How to get HttpRequestContext when I am using Self Hosted Owin?

How to get HttpRequestContext when I am using Self Hosted Owin?
My class is being called by ApplicationInsights and not by a controller, so I don't have access to any context.
Is there any way similar to what we do using HttpContext?
There is no static class to retrieve the request when using OWIN self hosted, because you are essentially in a console application, which is unaware that you wrote code that receives http requests.
Owin is a pipeline. The request is passed from middleware to middleware by calling the next middleware with a context parameter containing the request (and the response for that matter).
Each middleware registered in the pipeline can inspect the request on the way in, in their registration order, and call the next middleware before processing the response.
It is very easy to write your own middleware, register it in the pipeline, and inspect the request object for each request coming in.
Take a look here if you need a quick code example : http://benfoster.io/blog/how-to-write-owin-middleware-in-5-different-steps

Resources