JiraRestApi\Field\FieldService::create PHP Method

create() public method

create new field.
public create ( Field $field ) : created
$field Field object of Field class
return created field class
    public function create(Field $field)
    {
        $data = json_encode($field);
        $this->log->addInfo("Create Field=\n" . $data);
        $ret = $this->exec($this->uri, $data, 'POST');
        $cf = $this->json_mapper->map(json_decode($ret), new Field());
        return $cf;
    }

Usage Example

 public function testCreateFields()
 {
     //$this->markTestSkipped();
     try {
         $field = new Field();
         $field->setName('New custom field')->setDescription('Custom field for picking groups')->setType('com.atlassian.jira.plugin.system.customfieldtypes:grouppicker')->setSearcherKey('com.atlassian.jira.plugin.system.customfieldtypes:grouppickersearcher');
         $fieldService = new FieldService();
         $ret = $fieldService->create($field);
         Dumper::dump($ret);
     } catch (JiraException $e) {
         $this->assertTrue(false, 'Field Create Failed : ' . $e->getMessage());
     }
 }