jira-node / node-jira-client

A Node.js wrapper for the Jira REST API
https://jira-node.github.io/
MIT License
449 stars 168 forks source link

Allow to use GET (not only POST) for `/search` endpoint #368

Open Porok12 opened 6 months ago

Porok12 commented 6 months ago

Is there possibility to switch to version with GET (instead of POST) like python client has? I can only use GET method, POST will fail.

Porok12 commented 6 months ago

My workaround:

diff --git a/node_modules/jira-client/lib/jira.js b/node_modules/jira-client/lib/jira.js
index b94c316..7381301 100644
--- a/node_modules/jira-client/lib/jira.js
+++ b/node_modules/jira-client/lib/jira.js
@@ -740,14 +740,12 @@ class JiraApi {

   searchJira(searchString, optional = {}) {
     return this.doRequest(this.makeRequestHeader(this.makeUri({
-      pathname: '/search'
-    }), {
-      method: 'POST',
-      followAllRedirects: true,
-      body: {
+      pathname: '/search',
+      query: {
         jql: searchString,
         ...optional
       }
+    }), {
+      followAllRedirects: true,
     }));
   }
   /** Create a Jira user
Seth10001 commented 6 months ago

Per their docs:

If the JQL query expression is too large to be encoded as a query parameter, use the POST version of this resource.

The benefit of using the POST method is larger search strings can be passed. Could you paste the error message you're reciveing when using the POST method?

Porok12 commented 6 months ago

I'm getting 403 forbidden, maybe server don't have/handle post requests for some reason.

Query params can be very long so there should not be any problem with jql query lenght.

https://stackoverflow.com/questions/812925/what-is-the-maximum-possible-length-of-a-query-string#812962

Maybe lets user decide which one should be used?