Project

General

Profile

Actions

Feature #8195

closed

Create an issue with custom fields values

Added by Stéphane Schoorens almost 13 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
REST API
Target version:
-
Start date:
2011-04-20
Due date:
% Done:

100%

Estimated time:
Resolution:
Invalid

Description

I need the custom field tag for a post action

related :
http://www.redmine.org/projects/redmine/wiki/Rest_Issues

Actions #1

Updated by Etienne Massip almost 13 years ago

I think that it can be done ; did you try with

  <?xml version="1.0"?>
  <issue>
    <subject>Example</subject>
    <project_id>1</project_id>
    <priority_id>4</priority_id>
...
    <custom_values>
      <custom_value>
        <custom_field_id>2</custom_field_id>
        <value>Hello world !</value>
      </custom_value>
    </custom_values>
...
  </issue>
?

Actions #2

Updated by Etienne Massip almost 13 years ago

  • Subject changed from REST API for posting an issue to Create an issue with custom fields values
Actions #3

Updated by Stéphane Schoorens almost 13 years ago

I use my REST API for transform name into id
I use this type of data :
my $valeurs = {
issue => {
tracker => 'Anomalie',
status => 'In Progress',
priority => 'Urgent',
subject => 'new',
description => 'helloworld,
category => 'Module',
project => 'test',
custom_values => {
custom_value => {
custom_field_id => 3,
value[or name] => '123',
},
},
},
};
i'm using a json encoded and i post it after
and custom values doesn't work .

my api: https://github.com/sschoorens/Net--Redmine--API--REST
not yet on cpan i'm in dev

Actions #4

Updated by Etienne Massip almost 13 years ago

custom_field_values is a safe attribute of Issue which requires the issue id as it's used for a many-to-many relationship and this case may not be handled by code in IssueController#build_from_params@ (source:trunk/app/controllers/issues_controller.rb#L311).

Maybe a subsequent /edit POST request to add the custom values with new issue's id specified could do the job, not sure though.

Actions #5

Updated by Stéphane Schoorens almost 13 years ago

I've tried to make a PUT request on a issue with that values :

my $refhash = {
issue => {
custom_values => {
custom_value => {
custom_field_id => 12,
value => 'france',
},
},
notes => 'put custom',
},
};

but just the notes was added.

Actions #6

Updated by Stéphane Schoorens almost 13 years ago

I've tried to make a PUT request on a issue with that values :

@my $refhash = {
@ issue => {
@ custom_values => {
@ custom_value => {
@ custom_field_id => 12,
@ value => 'france',
@ },
@ },
@ notes => 'put custom',
@ },
@@ };

but just the notes was added.

Actions #7

Updated by Stéphane Schoorens almost 13 years ago

double post sorry can you remove it ? and how include code with @@?

Actions #8

Updated by Etienne Massip almost 13 years ago

Surround your multiline code with

<pre><code class="javascript">...</code>

Actions #9

Updated by Stéphane Schoorens almost 13 years ago

I've tried to make a PUT request on a issue with that values :

my $refhash = {
               issue => {
                         custom_values => {
                                           custom_value => {
                                                           custom_field_id => 12,
                                                           value => 'france',
                                                           },
                                          },
                         notes => 'put custom',
                         },
              };


but just the notes was added.

Actions #10

Updated by Etienne Massip almost 13 years ago

Could you try to edit issue with PUT /issues/[issue_id].json of

{
  issue => {
    custom_values => {
      custom_value => {
        customized_type => 'issue',
        customized_id => [issue_id],
        custom_field => 'my custom field',
        value => 'france',
      },
    },
    notes => 'put custom',
  },
};

?

Actions #11

Updated by Stéphane Schoorens almost 13 years ago

I've tried this on a custom field who's name 'Origine' :

  {
    issue => {
      custom_values => {
        custom_value => {
          customized_type => 'issue',
          customized_id => '424',
          custom_field => 'Origine',
          value => 'france',
        },
     },
     notes => 'put custom',
   },
  };

Only the notes is put.

Actions #12

Updated by Stéphane Schoorens almost 13 years ago

This is the return of json encode of an issue :

"custom_fields":[{"value":"","name":"Resolution","id":2}]

so I've tested the same like this :
{
        issue => {
            custom_fields =>[ {
                           id => '12',
                           value => '',
                           name => 'france',
            } ],
            notes => 'put custom',
        },
      };

but already only the notes are update.

Actions #13

Updated by Etienne Massip almost 13 years ago

  • Target version set to Candidate for next major release
Actions #14

Updated by Etienne Massip almost 13 years ago

  • Target version deleted (Candidate for next major release)

Could you please try the syntax described in RE: REST API json/xml syntax for updating/creating issues ?

Actions #15

Updated by Stéphane Schoorens almost 13 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100

It works =p ! thanks you it works also with a POST

Actions #16

Updated by Etienne Massip almost 13 years ago

If you have a few time, could you please add some doc about this in REST issues wiki page, that would be very nice ?

Or simply copy a full working example here so I could update wiki page myself.

Thanks !

Actions #17

Updated by Etienne Massip almost 13 years ago

  • Status changed from Resolved to Closed
  • Resolution set to Invalid
Actions #18

Updated by Stéphane Schoorens almost 13 years ago

I've add the field for custom value in the wiki where the posting with json is explain

Actions #19

Updated by Etienne Massip almost 13 years ago

Thanks a lot !

Actions #20

Updated by Curtis Weatherford about 6 years ago

Stéphane Schoorens wrote:

I've add the field for custom value in the wiki where the posting with json is explain

Could you please add a link to this because I can't seem to find it.

Actions

Also available in: Atom PDF