<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial,helvetica,sans-serif;font-size:12pt;color:#c00000;"><div><span style="color: rgb(0, 0, 0);">I first posted the message below to rt-users thinking I was doing something wrong in my application's PHP code that is trying to submit a REST request to RT.... but having added debugging comments to RT code I think possibly there could be a bug? Please read and then look below for the rest of this message...<br></span><br style="color: rgb(0, 64, 127);"><font style="color: rgb(0, 64, 127);" face="Tahoma" size="2"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> "vtplymblfan-rt@yahoo.com" <vtplymblfan-rt@yahoo.com><br><b><span style="font-weight: bold;">To:</span></b> rt-users@lists.bestpractical.com<br><b><span style="font-weight: bold;">Sent:</span></b> Tuesday, May 19, 2009 12:53:21 PM<br><b><span style="font-weight:
bold;">Subject:</span></b> [rt-users] any ideas why this post with php CURL not setting custom field?<br></font><br style="color: rgb(0, 64, 127);"><span style="color: rgb(0, 64, 127);">
Hi there,</span><br style="color: rgb(0, 64, 127);"><br style="color: rgb(0, 64, 127);"><span style="color: rgb(0, 64, 127);">I
have modified a web application to post to RT's web interface a create
ticket request. The post works perfectly... the ticket get created in
the right queue with the given subject and text... except that the
custom field value I pass (UPC) in does not get set. Here is the CURL
code:</span><br style="color: rgb(0, 64, 127);"><br style="color: rgb(0, 64, 127);"><span style="color: rgb(0, 64, 127);">----</span><br style="color: rgb(0, 64, 127);"><br style="color: rgb(0, 64, 127);"><span style="color: rgb(0, 64, 127);"> $content = 'id: new</span><br style="color: rgb(0, 64, 127);"><span style="color: rgb(0, 64, 127);">CF-UPC: 786936180992</span><br style="color: rgb(0, 64, 127);"><span style="color: rgb(0, 64, 127);">Text: This is the ticket text</span><br style="color: rgb(0, 64, 127);"><span style="color: rgb(0, 64, 127);">Subject: This is the subject</span><br style="color: rgb(0, 64, 127);"><span style="color: rgb(0, 64, 127);">Queue: External App Requests';</span><br style="color: rgb(0, 64, 127);"><br style="color: rgb(0, 64, 127);"><span style="color: rgb(0, 64, 127);"> $request = RT_LOCATION;</span><br style="color: rgb(0, 64, 127);"><span style="color: rgb(0, 64,
127);"> $request .= 'ticket/new/';</span><br style="color: rgb(0, 64, 127);"><br style="color: rgb(0, 64, 127);"><span style="color: rgb(0, 64, 127);"> $postargs = array(</span><br style="color: rgb(0, 64, 127);"><span style="color: rgb(0, 64, 127);"> 'user' => RT_USER,</span><br style="color: rgb(0, 64, 127);"><span style="color: rgb(0, 64, 127);"> 'pass' => RT_PASS,</span><br style="color: rgb(0, 64, 127);"><span style="color: rgb(0, 64, 127);"> 'content'
=> $content</span><br style="color: rgb(0, 64, 127);"><span style="color: rgb(0, 64, 127);"> );</span><br style="color: rgb(0, 64, 127);"><br style="color: rgb(0, 64, 127);"><span style="color: rgb(0, 64, 127);"> // get the curl session object</span><br style="color: rgb(0, 64, 127);"><span style="color: rgb(0, 64, 127);"> $session = curl_init($request);</span><br style="color: rgb(0, 64, 127);"><br style="color: rgb(0, 64, 127);"><span style="color: rgb(0, 64, 127);"> // set the POST options</span><br style="color: rgb(0, 64, 127);"><span style="color: rgb(0, 64, 127);"> curl_setopt ($session, CURLOPT_POST, true);</span><br style="color: rgb(0, 64, 127);"><span style="color: rgb(0, 64, 127);"> curl_setopt ($session, CURLOPT_POSTFIELDS, $postargs);</span><br style="color: rgb(0, 64, 127);"><span style="color: rgb(0, 64,
127);"> curl_setopt($session, CURLOPT_HEADER, true);</span><br style="color: rgb(0, 64, 127);"><span style="color: rgb(0, 64, 127);"> curl_setopt($session, CURLOPT_RETURNTRANSFER, true);</span><br style="color: rgb(0, 64, 127);"><span style="color: rgb(0, 64, 127);"> curl_setopt( $session, CURLOPT_HTTPHEADER, array( 'Expect:' ) );</span><br style="color: rgb(0, 64, 127);"><br style="color: rgb(0, 64, 127);"><span style="color: rgb(0, 64, 127);"> // do the POST and then close the session</span><br style="color: rgb(0, 64, 127);"><span style="color: rgb(0, 64, 127);"> $response = curl_exec($session);</span><br style="color: rgb(0, 64, 127);"><span style="color: rgb(0, 64, 127);"> curl_close($session);</span><br style="color: rgb(0, 64, 127);"><br style="color: rgb(0, 64, 127);"><span style="color: rgb(0, 64, 127);">---</span><br style="color: rgb(0,
64, 127);"><br style="color: rgb(0, 64, 127);"><span style="color: rgb(0, 64, 127);">In debugging this I have also created a simple form which posts to the same place:</span><br style="color: rgb(0, 64, 127);"><br style="color: rgb(0, 64, 127);"><pre style="color: rgb(0, 64, 127);" id="line1"><<span class="start-tag">form</span><span class="attribute-name"> method</span>=<span class="attribute-value">"POST"</span><span class="attribute-name">action</span>=<span class="attribute-value"><span>"<a rel="nofollow" target="_blank" href="http://foo.foo.edu/REST/1.0/ticket/new/">http://foo.foo.edu/REST/1.0/ticket/new/</a>"</span></span>><br>User: <<span class="start-tag">input</span><span class="attribute-name"> type</span>=<span class="attribute-value">"text" </span><span class="attribute-name">name</span>=<span class="attribute-value">"user" </span><span class="attribute-name">size</span>=<span class="attribute-value">"20"</span>><<span
class="start-tag">br</span>><br>Pass: <<span class="start-tag">input</span><span class="attribute-name"> type</span>=<span class="attribute-value">"text" </span><span class="attribute-name">name</span>=<span class="attribute-value">"pass" </span><span class="attribute-name">size</span>=<span class="attribute-value">"20"</span>><<span class="start-tag">br</span>><br>Content: <<span class="start-tag">textarea</span><span class="attribute-name"> rows</span>=<span class="attribute-value">"10" </span><span class="attribute-name">name</span>=<span class="attribute-value">"content" </span><span class="attribute-name">cols</span>=<span class="attribute-value">"30"</span>>id: new<br>CF-UPC: 786936180992<br>Text: This is the ticket text from the form.<br>Subject: This is the subject<br>Queue: External App Requests</<span class="end-tag">textarea</span>><<span class="start-tag">br</span>><br><<span
class="start-tag">p</span>><<span class="start-tag">input</span><span class="attribute-name"> type</span>=<span class="attribute-value">"submit" </span><span class="attribute-name">value</span>=<span class="attribute-value">"Submit" </span><span class="attribute-name">name</span>=<span class="attribute-value">"B1"</span>><span class="start-tag"></span><br></<span class="end-tag">form</span>> <br><br><span style="font-family: arial,helvetica,sans-serif;">When this form is used, again the ticket is created but in this case the custom field UPC <span style="font-style: italic; font-weight: bold;">does</span> </span><span style="font-family: arial,helvetica,sans-serif;">get set. But <br>the "Content:" being sent is the same in both. In particular in both cases I am providing UPC's value with <br>"CF-UPC: 78..." Can anyone here explain what the difference could possibly be between these two<br>posting methods that could result in this
scenario? By the way, in both cases I am passing in the same <br>user name and password. I am really stumped and I suspect some small stupid thing I have missed.<br><br>Thanks for your help,<br>Kim</span><br><font style="color: rgb(0, 64, 127);" face="Tahoma" size="2"><hr size="1"><b><span style="font-weight: bold;"></span></b><b><span style="font-weight: bold;"></span></b></font><span style="color: rgb(0, 0, 0); font-family: arial,helvetica,sans-serif;"><br>Ok so I decided to add comments to REST/1.0/Forms/ticket/default to see what RT was receiving in either case:<br><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> else {</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> # We'll create a new ticket, and fall through to set fields
that</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> # can't be set in the call to Create().</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> my (%v, $text);</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> foreach my $k (keys %data) {</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">push(@comments, "------------key: $k----------");</span><br style="font-family:
Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> # flexibly parse any dates</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> if ($dates{lc $k}) {</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> my $time = new RT::Date $session{CurrentUser};</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> $time->Set(Format => 'unknown', Value => $data{$k});</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">
$data{$k} = $time->ISO;</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> }</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> if (exists $create{lc $k}) {</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">push(@comments, "key $k in create");</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> $v{$create{lc $k}} = delete $data{$k};</span><br style="font-family: Courier
New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> }</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> # Set custom field</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> elsif ($k =~ /^$cf_spec/) {</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">push(@comments, "GOT HERE with $k");</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> my $cf = RT::CustomField->new( $RT::SystemUser );</span><br style="font-family:
Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">push(@comments, "cf: $cf");</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> my $cfk = $1 || $2;</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">push(@comments, "cfk: $cfk");</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> unless($cf->LoadByName( Name => $cfk )) {</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> push @comments, "# Invalid custom field
name ($cfk)";</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> delete $data{$k};</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> next;</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> }</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">push(@comments, "value: $data{$k}");</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> my($foo) = $cf->Id();</span><br
style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">push(@comments, "foo: $foo");</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> $v{"CustomField-".$cf->Id()} = delete $data{$k};</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">push(@comments, "v: $v{'CustomField-'.$foo}");</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> }</span><br><br>And I have dicovered that either way I try to create a ticket, either with the PPH CURL code or with the
form, the comments that get spit out are the same:<br><br style="color: rgb(0, 0, 0); font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">------------key: Subject----------</span></span><br style="color: rgb(0, 0, 0); font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="color: rgb(0, 0, 0); font-family: Courier New,courier,monaco,monospace,sans-serif;">key Subject in create</span><br style="color: rgb(0, 0, 0); font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="color: rgb(0, 0, 0); font-family: Courier New,courier,monaco,monospace,sans-serif;">------------key: id----------</span><br style="color: rgb(0, 0, 0); font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="color: rgb(0, 0, 0); font-family: Courier New,courier,monaco,monospace,sans-serif;">------------key: CF-UPC----------</span><br
style="color: rgb(0, 0, 0); font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="color: rgb(0, 0, 0); font-family: Courier New,courier,monaco,monospace,sans-serif;">GOT HERE with CF-UPC</span><br style="color: rgb(0, 0, 0); font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="color: rgb(0, 0, 0); font-family: Courier New,courier,monaco,monospace,sans-serif;">cf: RT::CustomField=HASH(0x5555592bf510)</span><br style="color: rgb(0, 0, 0); font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="color: rgb(0, 0, 0); font-family: Courier New,courier,monaco,monospace,sans-serif;">cfk: UPC</span><br style="color: rgb(0, 0, 0); font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="color: rgb(0, 0, 0); font-family: Courier New,courier,monaco,monospace,sans-serif;">value: 786936180992</span><br style="color: rgb(0, 0, 0); font-family: Courier
New,courier,monaco,monospace,sans-serif;"><span style="color: rgb(0, 0, 0); font-family: Courier New,courier,monaco,monospace,sans-serif;">foo: 1</span><br style="color: rgb(0, 0, 0); font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="color: rgb(0, 0, 0); font-family: Courier New,courier,monaco,monospace,sans-serif;">v: 786936180992</span><br style="color: rgb(0, 0, 0); font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="color: rgb(0, 0, 0); font-family: Courier New,courier,monaco,monospace,sans-serif;">------------key: Queue----------</span><br style="color: rgb(0, 0, 0); font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="color: rgb(0, 0, 0); font-family: Courier New,courier,monaco,monospace,sans-serif;">key Queue in create</span><br style="color: rgb(0, 0, 0); font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="color: rgb(0, 0, 0); font-family: Courier
New,courier,monaco,monospace,sans-serif;">------------key: Text----------</span><br><br><span style="color: rgb(0, 0, 0);"><span style="font-family: arial,helvetica,sans-serif;"><br>So it appears that in both cases Forms/ticket/default is getting exactly the same thing and doing with it exactly the same thing.... specifically<br>taking in CF-UPC: 7893... and with that creating the custom field UPC with value 7893...<br><br>So then why in one case does the resulting ticket I find when I go to RT have this custom field set and in the other case not? Please are there any <br>ticket creation experts who could shed light on what is going wrong after the request is processed in Forms/ticket/default?<br><br>Thanks so much for your help,<br>Kim Jones</span><font size="2"><span style="font-family: arial,helvetica,sans-serif;"></span></font></span> <br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><br><br><br></pre><br><br><div
style="font-family: arial,helvetica,sans-serif; font-size: 12pt;"><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><div><br></div></div></div></div><br></div></div></body></html>