Closed jonaslepsoy closed 3 years ago
I need this for our FotoWare integration app.
Do you have a test example that demonstrates "PATCH" not working?
Well it requires an auth token, so it's a bit of work to setup...
Doc says
method (string) The HTTP method to use for the request (e.g. "POST", "GET", "HEAD", "PUT", "DELETE"). The default value is "GET".
But it does not mean that "PATCH" is not supported. e.g. here translates to "for example".
You can't trust the docs...
This doesn't work: https://github.com/enonic/app-fotoware/blob/master/src/main/resources/lib/fotoware/api/asset/update.es#L40
However sending the exact same parameters through Postman works fine.
simple server: nc -l localhost 8000
how to send patch
var http = require('/lib/http-client');
var result = http.request({
url: 'http://localhost:8000/my/url',
method: 'patch',
body: 'PATCH body'
});
nc Output
PATCH /my/url HTTP/1.1
Content-Length: 10
Host: localhost:8000
Connection: Keep-Alive
Accept-Encoding: gzip
User-Agent: okhttp/4.9.1
PATCH body
Library supports PATCH
Sooo method: 'patch' works, but method: 'PATCH' fails?
Notice the doc uses UPPERCASE letters in the example https://developer.enonic.com/docs/http-client-library/master#usage
Even the API doc https://developer.enonic.com/docs/http-client-library/master#api
PATCH
or patch
doesn't matter. value gets uppercased.
Could you try the same request you did above with Postman, just to see if there are any other differences than User-Agent?
The lib only supports "POST", "GET", "HEAD", "PUT", "DELETE". It should also support "PATCH".
This would be useful if some service modifies only some data fields and not all (where a PUT would be proper).