Azure / Azure/azure-functions-host
Very simple Custom Route based NodeJS Rest POST API getting 404 error
- Dominant language
- C#
- Stars
- 2k
- Forks
- 482
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 38
Description
I am creating some very simple REST API Stubs for testing purposes for a customer project and I am passing values into the REST API through a custom route. I am doing this based on REST APIs that will be developed by the customer, so I am trying to provide a way to test the integration with the REST APIs without actually having them developed. When I test this Function, I get a 404 error. I know that there is an existing issue that talks about problems with Custom Routes, but I am seeing where I should be expecting a 404 or how I can get around it.
#### Investigative information
Please provide the following:
- Timestamp:
- Function App version: (1.0.11820)
- Function App name: userprofile-stubs
- Function name(s) (as appropriate): UserProfile_PhonePOST
- Invocation ID:
- Region: East US 2
#### Repro steps
Using either the Test feature in the Portal or using the provided URL, I get a 404 error.
#### Expected behavior
I expect to get a simple body Response that says Success
#### Related information
* Programming language used - Javascript
module.exports = function (context, req) {
context.log('JavaScript HTTP trigger function processed a request.');
// As this is only a stub, we just need to make sure that we receive all of the correct pieces
// pieces of information to actually process the request and then send the success or error back.
var action = context.bindingData.action;
var phoneType = context.bindingData.type;
var phoneNo = context.bindingData.phone;
if (action && phoneType && phoneNo) {
context.res = {
// status: 200, /* Defaults to 200 */
body: "SUCCESS"
};
}
else {
context.res = {
status: 400,
body: "One or more of the required values were not passed into the REST service."
};
}
context.done();
};
Contributor guide
Research direction
Start by reproducing the POST through the Portal Test feature or the provided URL for UserProfile_PhonePOST, then inspect the custom route configuration and the bindingData values action, type, and phone. Done means the request reaches the function and returns the expected SUCCESS body instead of 404.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, javascript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100