Forums

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

Troubles with PUT in AP.request within AC IFrame

Tom Pom April 13, 2018

Trouble is: PUT is successful, no error code but data not updated.

On the client side within my Atlassian Connect IFrame I am trying to send a PUT request as below.

scopes in my descriptor.json:

"scopes": [
    "read", 
    "write", 
    "delete"
  ], 

This is run on my dev instance of JIRA cloud under admin user.

Request:

AP.request({
        url: '/rest/api/2/issue/XCV-17',
        method: 'PUT',
        data: { "update": { "labels": [ { "add": "zzz" } ] } },
        dataType: 'json',
        contentType: 'application/json',
        success: function(msg) { alert("success:\n" + JSON.stringify(msg)); },
        error: function(msg) { alert("error:\n" + JSON.stringify(msg)); }
      });

 

I am not receiving any error code. In fact, I see success callback being triggered (with payload containing all the JIRA issue data), yet there are no label updated/created on the issue (tried refreshing the page, opening edit dialog after the request - nothing).

In the console I see this mystic warning "[Simple-XDM] Failed to validate origin: https://xxxx.atlassian.net"

I created the request to avoid CORS per https://developer.atlassian.com/cloud/jira/platform/jsapi/request/

REST API doc: https://developer.atlassian.com/cloud/jira/platform/rest/#api-api-2-issue-issueIdOrKey-put

 

A similar GET request I run on the same IFrame is successful and returns valid data every time.

I tried stringifying the data I am passing into the PUT request - no change.

 

I am quite stuck with this and would appreciate any direction.

1 answer

1 accepted

0 votes
Answer accepted
Tom Pom April 13, 2018

Unfortunately, my mistake is the issue here :-( An embarrassing one as well.

There is no such option parameter as

method: 'PUT',

it should have been

type: 'PUT',

 Replacing "method" with "type" fixed my problem.

 

Not sure this will ever help anyone as documentation clearly says "type" ("method" is not mentioned anywhere - not sure where I got that).

 

So, what happened was AP.request simply ignored "method" parameter and assumed request to be a GET one. It then fetched all available data for "/rest/api/2/issue/XCV-17" - that is why I did not get any error but "200, OK".

Since this the first time I tried the REST API, I did not suspect anything wrong with PUT returning all that data. Though, I should have checked the network exchange during request before submitting this question.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events