Restful Table create entry - Request Method: PUT instead of POST

Hi all,

may one can help me with my problem.

I have created a customfield where one should be able to associate the options to several users.
In my table I want to show the associated options to a user and also add them to.
The table row view is also working fine.

I’ve created a Restful table inside my *.js file as:

var CustomDataCreate = AJS.RestfulTable.CustomCreateView.extend({
      render : function(self) {
        var $select = $('<select name="id" class="select" id="create-data-select"></select>');
        $.each($pData,function(i,v){
          if ( !v.optionDisabled){
            $select.append('<option value="' + v.id + '">' + v.value + '</option>');
          }
        });
        return $select;
      }
});

skillTable = new AJS.RestfulTable({
      el: $('#table-user-data'),
      allowCreate: true,
      allowEdit: false,
      allowDelete: true,
      allowReorder: true,
      autoFocus: false,
      deleteConfirmation: DeleteConfirmationPopUp,
      noEntriesMsg: "No data associations defined",
      resources: {
        all: url + "user/" + userKey + "/data",
        self: url + "user/" + userKey + "/data"
      },
      columns: [
        {
          id: "value",
          header: "Name",
          **createView: CustomDataCreate**
        }
      ]
});

My web-resource:

<web-resource key="data-resouce-resources" name="Data resource Web Resources">
    <dependency>com.atlassian.auiplugin:ajs</dependency>
    <dependency>com.atlassian.auiplugin:aui-date-picker</dependency>
    <dependency>com.atlassian.auiplugin:aui-flag</dependency>
    <dependency>com.atlassian.auiplugin:aui-select2</dependency>
    <dependency>com.atlassian.auiplugin:aui-experimental-restfultable</dependency>
    <resource type="download" name="data-resouce.css" location="/css/data-resouce.css"/>
    <resource type="download" name="data-resouce.js" location="/js/data-resouce.js"/>
    <resource type="download" name="images/" location="/images"/>
    <context>data-resouce</context>
  </web-resource>

My REST Endpoint works fine, when I use it in the REST API Browser (there’re no problems)

As soon as I use in columns my custom “createView” the add method does a request using PUT instead of POST

image

  • The data which is sent is fine
  • The select field i displayed as expected
  • deleting an row does also work!

What I have already figured out:
If I do not use my createView the add button does a POST request to the given url.

I do have another Restful table in the same javascript which works fine when creating a new row.
There I also do use a custom createView (even with date pickers)

Is there any way to override the event for “Add”?
Or maybe anyone does see a mistake in my code^^

Jira v7.1.9 (Software)

Kind Regards
Dominik

1 Like
 var $select = $('<select name="id" class="select" id="create-data-select"></select>');

The reason is because name=“id” causes it to think it is a created record.
id should not be used.

Took me some time to realise that :sweat: