The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

411 error while trying to POST to an api

Vineela Durbha
Contributor
April 23, 2019

I am using below code to update fields using api

def baseUrl = new URL("http://xxxx/xxxxxxx/abc");

HttpURLConnection conn= (HttpURLConnection) baseUrl.openConnection();
log.debug(conn.getContentLength())
conn.setInstanceFollowRedirects( false );

conn.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
conn.setRequestProperty("Accept", "application/json");

conn.setDoOutput(true);
conn.setDoInput(true);
conn.setRequestMethod("POST");
//conn.connect();
log.debug(conn.getResponseCode() as String)

 

But I am receiving 411 error , not sure on how to set content length.can someone help me with this

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
mark.yin
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 12, 2024

Try to use "Customer Data" from "JIRA Automation"

0 votes
Andy Heinzer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
April 24, 2019

Hi,

I'm not sure how exactly you're getting this error.  Is this Jira Cloud or Jira Server?  If Server what version of Jira is this?

Also what specific REST endpoint are you using when trying to POST here?   What payload is being sent via REST here?

I found a few related threads in community to this, such as https://community.atlassian.com/t5/Answers-Developer-Questions/Bamboo-REST-API-to-create-branches/qaq-p/477013 which suggests to look at https://serverfault.com/questions/164220/is-there-a-way-to-avoid-nginx-411-content-length-required-errors

Which indicates this could be a proxy problem, that you can work around with the header of

curl -i -X PUT -H 'Content-Length: 0' 'http://www.example.com/test'

Perhaps this can help. 

Please let me know.

Andy