GithubHelp home page GithubHelp logo

Comments (15)

aacerox avatar aacerox commented on July 19, 2024

could you please try this?

var Client = require('node-rest-client').Client

var defaultOptions = {    
    user: 'myuser',
    password: 'mypassword',
    mimetypes: {
        json: ["application/json", "application/json;charset=utf-8"]
    }
};

var client = new Client(defaultOptions);

var args ={headers:{"Content-Type": "application/json"}};

client.delete('http://localhost:8080/rest/service/5117',args, function(data, response) { ... }); 

from node-rest-client.

rkmax avatar rkmax commented on July 19, 2024

@aacerox same problem

Here are the requests

Generated by client.delete

DELETE /rest/service/5117 HTTP/1.1
Host: localhost:8080
Authorization: Basic dXNlcjpwYXNzd29yZA==
Connection: keep-alive
Transfer-Encoding: chunked

0

Generated by request (working)

DELETE /rest/service/5117 HTTP/1.1
Host: localhost:8080
Content-Type: application/json
Authorization: Basic dXNlcjpwYXNzd29yZA==
content-length: 0

from node-rest-client.

aacerox avatar aacerox commented on July 19, 2024

hi @rkmax

I've tried DELETE method several times with different REST sites and works without problems. for example:

var Client = require('node-rest-client').Client;
var defaultOptions = {    
    user: 'myuser',
    password: 'mypassword',
    mimetypes: {
        json: ["application/json", "application/json;charset=utf-8"]
    }
};

var client = new Client(defaultOptions);

var args ={headers:{"Content-Type": "application/json"}};

client.delete('http://jsonplaceholder.typicode.com/posts/1',args, function(data, response) { 

    console.log(data);
 }); 

I see your testing against a local server. Is it private or are you using any that I can download to try by my self?

How do you get the requests logs you sent me the last comment?

Thanks.

from node-rest-client.

rkmax avatar rkmax commented on July 19, 2024

@aacerox i using for communicate with activiti.org activiti-rest.

I get the request logs using http://www.charlesproxy.com/

from node-rest-client.

aacerox avatar aacerox commented on July 19, 2024

the activity REST API documentation mention this:

Due to default security properties on Tomcat, escaped forward slashes (%2F and %5C) are 
not allowed by default (400-result is returned). This may have an impact on the deployment 
resources and their data-URL, as the URL can potentially contain escaped forward slashes.

When issues are experienced with unexpected 400-results, set the following system-property: 
-Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true.

could you check to set this property an see if it works? I know you're not using escaped forward slashes in your URL but I need to discard possible causes.

Also you can enable debug on the client by setting the env variable debug and send me the result

linux: export DEBUG=true

windows:set DEBUG=true

from node-rest-client.

rkmax avatar rkmax commented on July 19, 2024

@aacerox i'm using Glassfish.

I'm using node-rest-client to consume almost 60% of the API. Other methods GET, PUT POST, works fine with the exception of DELETE

from node-rest-client.

ncorison avatar ncorison commented on July 19, 2024

FYI: I am having the same problem. Interestingly, changing the method from DELETE to GET and the call works fine; change it back to DELETE and it fails. Added "content-length: 0" to my header and it worked!

from node-rest-client.

ncorison avatar ncorison commented on July 19, 2024

Please note that the latest version of Apache requires "content-length" in the header or Apache will reject the request with a 500 error - your server will never see the request! I have had issues with node-rest-client's POST and DELETE because of this.

from node-rest-client.

aacerox avatar aacerox commented on July 19, 2024

Thanks @ncorison

Time ago I had a similar problem with nginx and solved it adding Content-Length to every POST and PUT method requests, but I forgot DELETE method (my fault ...).

Tonight I'll set Content-Length header to DELETE method too, and I'll upload a new version with these changes.

from node-rest-client.

aacerox avatar aacerox commented on July 19, 2024

Hi @rkmax and @ncorison

I've created a branch "issue64-delete-method" with the fix I point to @ncorison in the last post (setting always "Content-length" header in every POST/PUT/DELETE/PATCH method request).

Could you please test your code against this branch to see if we have found a solution?

Thanks.

from node-rest-client.

rkmax avatar rkmax commented on July 19, 2024

Thanks @aacerox I'll try it this weekend

from node-rest-client.

aacerox avatar aacerox commented on July 19, 2024

Hi @rkmax and @ncorison

have you been able to test your code agains branch "issue64-delete-method" during the weekend?

from node-rest-client.

ncorison avatar ncorison commented on July 19, 2024

No, I have not - it will need to wait until tomorrow at the earliest.

Norman


From: Alejandro Alvarez Acero [mailto:[email protected]]
Sent: Monday, April 13, 2015 2:02 AM
To: aacerox/node-rest-client
Cc: Norman Corison
Subject: Re: [node-rest-client] delete method is not working well (#64)

Hi @rkmaxhttps://github.com/rkmax and @ncorisonhttps://github.com/ncorison

have you been able to test your code agains branch "issue64-delete-method" during the weekend?

Reply to this email directly or view it on GitHubhttps://github.com//issues/64#issuecomment-92278734.

from node-rest-client.

ncorison avatar ncorison commented on July 19, 2024

Looks like it's working OK for me.

Norman


From: Alejandro Alvarez Acero [mailto:[email protected]]
Sent: Friday, April 10, 2015 2:14 PM
To: aacerox/node-rest-client
Cc: Norman Corison
Subject: Re: [node-rest-client] delete method is not working well (#64)

Hi @rkmaxhttps://github.com/rkmax and @ncorisonhttps://github.com/ncorison

I've created a branch "issue64-delete-method" with the fix I point to @ncorisonhttps://github.com/ncorison in the last post (setting always "Content-length" header in every POST/PUT/DELETE/PATCH method request).

Could you please test your code against this branch to see if we have found a solution?

Thanks.

Reply to this email directly or view it on GitHubhttps://github.com//issues/64#issuecomment-91693427.

from node-rest-client.

aacerox avatar aacerox commented on July 19, 2024

I assume this is fixed, so I close this issue. If not please reopen.

from node-rest-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.