dongyuan2652 2017-08-01 17:11
浏览 76

内容请求跟踪器(RT)REST API错误

I have tried posting the HTTP request multiple ways (both using PHP and Python) and I keep getting this error

string(341) "Can't use an undefined value as an ARRAY reference at /opt/rt4/share/html/REST/1.0/dhandler line 189.

Stack:
  [/opt/rt4/share/html/REST/1.0/dhandler:189]
  [/opt/rt4/share/html/REST/1.0/autohandler:54]
  [/opt/rt4/sbin/../lib/RT/Interface/Web.pm:634]
  [/opt/rt4/sbin/../lib/RT/Interface/Web.pm:334]
  [/opt/rt4/share/html/autohandler:53]

I tried to follow the RT REST Guide but I cant seem to install the HttpRequest they are using and I cant find the source code for it online.

Does anyone have any advice?

Here is my python code:

import cookielib
import urllib
import urllib2

# creates a cookie for the rtserver with the credentials given at initialization.
# define your credentials here

# here is the RequestTracker URI we try to access
uri = 'http://ip:port/REST/1.0/ticket/1/edit?user=username&pass=password'

# trying login on rt server
cj = cookielib.LWPCookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
urllib2.install_opener(opener)
subdata = {'Subject': 'Test2', "Status":"open"}
data = {'content':subdata}
ldata = urllib.urlencode(data)
login = urllib2.Request(uri, ldata)
print(login.get_full_url())
try:
   response = urllib2.urlopen(login)
   print response.read()

except urllib2.URLError:
   # could not connect to server
   print "Not able to login"

And here is my php:

<?php
require('HttpRequest.php');
$username = 'username';
$password = 'password';
//set POST variables
$url = "http://ip:port/REST/1.0/ticket/1/edit?user=$username&pass=$password";
$fields = array("content"=>"Subject=Test2
Status=open
");

$request = new HttpRequest('post', $url, $fields);
print($request->toString());
$request->doRequest();
?>

With the HttpRequest coming from here

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 求差集那个函数有问题,有无佬可以解决
    • ¥15 【提问】基于Invest的水源涵养
    • ¥20 微信网友居然可以通过vx号找到我绑的手机号
    • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
    • ¥15 解riccati方程组
    • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
    • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
    • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
    • ¥50 树莓派安卓APK系统签名
    • ¥65 汇编语言除法溢出问题