POST, PATCH, and other methods not supported?
See original GitHub issueIssue Description
Hi there,
I’ve got a standard API that parses correctly in Apiary.io, and their mock server returns a 200, but drakov seems to always return “404: Cannot PATCH /groups/…”
Do non-GET requests need any special treatment? I’m using the example JS code in Apiary.io, and haven’t been able to get a valid response all day. Here’s the API:
FORMAT: 1A
# Group Users & Groups
## Group object [/groups/{id}]
+ Parameters
+ id (string, required)
Group ID.
### Get group [GET]
+ Response 200 (application/json)
+ Attributes
+ data (GROUP)
+ Response 400 (application/json)
+ Attributes (ERROR)
+ Response 404 (application/json)
### Modify group [PATCH]
+ Request (application/json)
{
"data": {
"id": "acme",
"type": "group",
"attributes": {
"contact_emails": [
"wcoyote@acme.com",
"rrunner@acme.com",
"bbunny@acme.com"
]
}
}
}
+ Response 200 (application/json)
+ Attributes
+ data (GROUP)
+ Response 400 (application/json)
+ Attributes (ERROR)
# GROUP
+ id: acme (string, required)
+ type: group (string, required)
+ attributes
+ organization: Acme (string, required)
+ organization_legal_name: Acme Inc. (string, required)
+ country_iso: us (string, required)
+ contact_emails: wcoyote@acme.com, rrunner@acme.com (array[string], required)
+ relationships
+ apikey
+ id: 57a24c23d0f49e1f13970f28a7a351b92f33b48c009dfefdaf2ce11140b2d456 (string, required)
+ type: apikey (string, required)
+ subscription
+ id: acme (string, required)
+ type: subscription (string, required)
+ administrators (array)
+ (object)
+ id: wcoyote
+ type: user
+ (object)
+ id: rrunner
+ type: user
And the CURL command:
curl --include \
--request PATCH \
--header "Content-Type: application/json" \
--data-binary " {
\"data\": {
\"id\": \"acme\",
\"type\": \"group\",
\"attributes\": {
\"contact_emails\": [
\"wcoyote@acme.com\",
\"rrunner@acme.com\",
\"bbunny@acme.com\"
]
}
}
} " \
'http://localhost:5000/api/v3/groups/id'
And this is the code I’m using to run drakov (from a gulpfile.js):
var gulp = require('gulp');
var express = require('express');
var drakov = require('drakov');
gulp.task('drakov', function() {
var argv = {
sourceFiles: './api/apiary.apib',
serverPort: 5000,
autoOptions: true,
method: ['PATCH', 'POST', 'PUT', 'DELETE', 'OPTIONS']
}
var app = express();
drakov.middleware.init(app, argv, (err, middleWareFunction) => {
app.use('/api/v3', middleWareFunction);
app.listen(argv.serverPort);
});
});
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
post method not supported in patch method - Stack Overflow
I want edit entity with validating by hibernate-validator, but when calling the patch method, an error is thrown: post method not supported ...
Read more >How to Fix Request Method 'POST' Not Supported - Hyperping
The Request Method' POST' Not Supported' is an HTTP response status. The error prompt shows that a request to access your website has...
Read more >The PATCH method is not supported for this route ... - Laracasts
Supported methods : GET, HEAD, POST. I get this error when updating the product, I use laravel 7.3, the browsers do not read...
Read more >PATCH - HTTP - MDN Web Docs
PATCH (like POST ) may have side-effects on other resources. To find out whether a server supports PATCH , a server can advertise...
Read more >RFC 5789: PATCH Method for HTTP
POST is already used but without broad interoperability (for one, there is no standard way to discover patch format support). PATCH was mentioned...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
An update for everyone watching this issue.
This is now under active investigation and I am hoping to have a fix/update in the next couple of weeks 👍
@yakovkhalinsky any updates on your “active” investigation 😃 ?