It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Failing with jQuery PUT and POST to JIRA REST API from Confluence Edited

The Confluence and JIRA are connected with an application link. (servers)

Developing Built in Macros for confluence.

jQuery GET works fine, PUT and POST fails with 400.

I succeed with similar call from postman.

Permissions, logins - everything checked.

I know that there are plugins to solve this, but then I loose control of exact behavior.

Example code - trying to modify an issue summary in JIRA

var theurl = encodeURI(confbase + "/plugins/servlet/applinks/proxy?appId=" + confproxy +"&path=" + jirabase + "/rest/api/latest/issue/SP-4");

var thePost = JSON.parse('{ "update": { "summary": [{ "set": "Modified Summary 2" } ] } }');

var jqxhr = jQuery.ajax({
type: "PUT",
url: theurl,
dataType: 'json',
data: JSON.stringify(thePost),
cache:false,
async: false
}).done(function (response) {
alert("Success");
}).fail(function(jqxhr, textStatus, errorThrown) {
var contentType = jqxhr.getResponseHeader("Content-Type");
var responseBody = jqxhr.responseText;
console.log(responseBody);
alert("Failed");
});;

 

Response when attempting:

HTTP method PUT is not supported by this URL

The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).

Apache Tomcat/9.0.19

 

Other PUT and POST problems encountered with confluence property:

https://community.atlassian.com/t5/Jira-questions/Create-modify-confluence-property-through-REST-API-fails/qaq-p/1216072#M388269 

Confluence server 6.15

1 answer

0 votes
Dario Atlassian Team Tuesday

Hi @zaphnet ,

I already replied the other thread. Since I believe the problem can be something similar in here as well. Can you kindly let me know which endpoint you are using in order to try to update an issue summary in Jira?

The only endpoint I can see in above code is the below one but it does not look correct:

var theurl = encodeURI(confbase + "/plugins/servlet/applinks/proxy?appId=" + confproxy +"&path=" + jirabase + "/rest/api/latest/issue/SP-4");

 

The REST API endpoint to update an issue in Jira Server 8.3 is:

http(s)://{JIRA}/rest/api/2/issue/{issueIdOrKey}

 

Can you kindly let me know which endpoint are you calling in order to try to update an issue summary in Jira?

Also, if this still fails, please try to run the exact same REST API call using Curl and paste the output in here (removing the sensitive data).

 

Cheers,
Dario

Thank for your reply. Replacing latest with 2 gives same result. Problem not solved.

GET from inside confluence works fine, but PUT or POST fails.

Postman and curl works fine:

curl.exe -u user:user -X PUT -H 'Content-Type: application/json' -d '{"update": { "summary": [{ "set": "Modified Summary 2" } ] } }' "https://jira-test.nnn.net/rest/api/2/issue/SP-4"

Not response object (as expected)

Summary of JIRA issue has been changed.

curl.exe -u user:user -X PUT -H 'Content-Type: application/json' -d '{"update": { "summary": [{ "set": "Modified Summary 3" } ] } }' "https://confluence-test.nnn.net/plugins/servlet/applinks/proxy?appId=nnn&path=https://jira-test.nnn.net/rest/api/2/issue/SP-4"

Also fails with

HTTP method PUT is not supported by this URL
 curl.exe -u user:user -X GET -H 'Content-Type: application/json'  "https://confluence-test.nnn.net/plugins/servlet/applinks/proxy?appId=nnn&path=https://jira-test.nnn.net/rest/api/2/issue/SP-4"

Returns the jira object OK.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

245 views 1 2
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you