Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

RESTful Table POST request is empty!

Arthur
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 Leaders.
May 23, 2013

yup, you read it correctly: its empty!

empty post request

In the image above the first thing you see is the aui restful table, with two input fields filled with "fgfsa" and "sdgw" and a "add" button.

After pressing ADD I get the error message in the console(lower part of the image). As you can see there is nothing in the post request.

Translating the text:"There are no child elements"

And here is the AJS.restful table backbone object:

new AJS.RestfulTable({
        autoFocus: true,
        el: jQuery("#config-fields-table"),
        allowReorder: true,
        noEntriesMsg: "Please add some ticket fields.",
        resources: {
            all: baseUrl +"/rest/otrs-config/1.0/ticketfield",
            self: baseUrl +"/rest/otrs-config/1.0/ticketfield/"
        },
        columns: [
            { id: "fieldname", header: AJS.I18n.getText("common.words.name")},
            { id: "colname", header: AJS.I18n.getText("common.words.description")}
        ]
    });

...and the java backend POST method:

@POST
    public Response createTicketField(final TicketField bean) {

        logger.error("=================================================================");
        logger.error("created ticketfield:" + bean);
        logger.error("=================================================================");

        return Response.ok(transactionTemplate.execute(new TransactionCallback() {

            @Override
            public Object doInTransaction() {
                PluginSettings settings = pluginSettingsFactory.createGlobalSettings();
                List<TicketField> fields = findAllTicketFields();

                TicketField newTicketField = new TicketField();
                newTicketField.setColname(bean.getColname());
                newTicketField.setFieldname(bean.getFieldname());
                newTicketField.setId(createTicketFieldID());

                if (fields.contains(newTicketField) == false) {
                    fields.add(newTicketField);
                }

                settings.put(fieldsListKey, fields);
                return newTicketField;

            }
        })).build();
    }

.... and the jax-ws wrapper class:

//==== inner class =====
    @XmlRootElement
    public class TicketField {

        @XmlElement
        private Integer id;
        
        @XmlElement
        private String fieldname;
        
        @XmlElement
        private String colname;

        public TicketField(){}
        
        public TicketField(String fieldname, String colname){
            this.fieldname = fieldname;
            this.colname = colname;
        }
        
        public String getColname() {
            return colname;
        }

        public void setColname(String colname) {
            this.colname = colname;
        }

        public String getFieldname() {
            return fieldname;
        }

        public void setFieldname(String fieldname) {
            this.fieldname = fieldname;
        }

        public Integer getId() {
            return id;
        }

        public void setId(Integer id) {
            this.id = id;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final TicketField other = (TicketField) obj;
            if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
                return false;
            }
            if ((this.fieldname == null) ? (other.fieldname != null) : !this.fieldname.equals(other.fieldname)) {
                return false;
            }
            return true;
        }

        @Override
        public int hashCode() {
            int hash = 7;
            hash = 67 * hash + (this.id != null ? this.id.hashCode() : 0);
            hash = 67 * hash + (this.fieldname != null ? this.fieldname.hashCode() : 0);
            return hash;
        }
        
        
    }

Why is the post empty?? Thanks in advance

4 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Holger Schimanski
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 Leaders.
April 27, 2015

I am using restful table in project configuration as a web-item in section atl.jira.proj.config/projectgroup3. To get the restful table working in JIRA 6.2 and above I have to add com.atlassian.jira.jira-project-config-plugin:project-config-restfultable as a dependency for my web-resources instead of com.atlassian.auiplugin:aui-experimental-restfultable.

<web-resource ...>
  <dependency>com.atlassian.jira.jira-project-config-plugin:project-config-global</dependency>
  <dependency>com.atlassian.jira.jira-project-config-plugin:project-config-restfultable</dependency>
  <!-- <dependency>com.atlassian.auiplugin:aui-experimental-restfultable</dependency> -->
  ...
</web-resource>

 

 

Leandro Coutinho May 19, 2017

In my case, it worked just adding the dependency: "com.atlassian.jira.jira-project-config-plugin:project-config-global"

<web-resource ...>
    <dependency>com.atlassian.jira.jira-project-config-plugin:project-config-global</dependency>
    <dependency>com.atlassian.auiplugin:aui-experimental-restfultable</dependency>
    <dependency>com.atlassian.auiplugin:dialog2</dependency>
    <dependency>com.atlassian.auiplugin:aui-select2</dependency>
</web-resource>
1 vote
Bernhard Grünewaldt April 11, 2014

Did you put the correct mediatypes for your createTicketField Method:

@Consumes ({ MediaType.APPLICATION_JSON })
@Produces ({ MediaType.APPLICATION_JSON })

And if the server says internal server error 500 there may also be an exception in the logfile.

Holger Schimanski
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 Leaders.
April 23, 2015

This helped me when updating from JIRA 6.0 to JIRA 6.1. But even with this annotation in JIRA 6.2 and higher again I have an empty JSON object when RESTful table is calling REST webservice. Any idea?

0 votes
Holger Schimanski
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 Leaders.
April 23, 2015

Okay, got it. It's the missing @Consumes ({ MediaType.APPLICATION_JSON }) also in my code as mentioned by Bernhard below. Looks like this was not checked by backbone.js or whatever component in JIRA 6.0. Works fine now in JIRA 6.1, but then again not working in JIRA 6.2 and higher! Any idea?

0 votes
Holger Schimanski
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 Leaders.
April 23, 2015

Did you found a solution for this problem of empty JSON object when using RESTful table? When switching from JIRA 6.0 to more recent versions I have the same problem.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events