Add an issue via PHP form

Added by Dan Michaels 7 months ago

Hi! I'm trying to figure out how to create an HTML form that lets me add an issue to a Redmine project via PHP. I've figured out the project ID and API key, and I'm using Redmine 3.3.0.

Unfortunately, the PHP examples on use PHP ActiveResource, and the ActiveResource link goes to a dead page.

So then I thought that maybe I can do without external libraries and just submit a form to the right place using the basic REST API documentation.

It says that to create an issue, I should use "POST /issues.[format]" and the parameter "issue - A hash of the issue attributes".

So I assume I should POST to e.g. the URL ?

But what does "A hash of the issue attributes" mean in this context? The example shows an XML snippet with the issue attributes, so I guess I should create a similar XML (or json) snippet and hash it, but using what function?

I've also seen examples using cURL, but they seem to have the XML/json in separate files, and I'd prefer to avoid that.

Basically: What's the simplest way for me to move forward and create a form in HTML+PHP that lets me add an issue to my Redmine project?

Replies (1)

RE: Add an issue via PHP form - Added by Dan Michaels 7 months ago

Update: I found a version of PHP ActiveResource to download, and tried using the PHP API example, but I'm not sure what syntax to use if I want to use the API key instead of username and password. Here's what I tried – the code runs but doesn't create any new Redmine issue:

require_once ('ActiveResource/lib/ActiveResource.php');

class Issue extends ActiveResource {
    var $site = '';
    var $request_format = 'xml'; 

// create a new issue
$issue = new Issue (array ('subject' => 'XML REST API issue creation test', 'project_id' => '17'));
$issue->save ();

Anyone have any idea why the above doesn't create a new issue?