bugzilla webservice bug.get 是否需要身份验证?

发布于 2024-10-21 02:45:30 字数 1827 浏览 7 评论 0原文

我正在使用 jsonrpc 访问 bugzilla webservice 的 bug.get 功能,但它正在返回:

错误:403
禁止的内容类型:text/xml
没有数据。

我对我的服务器进行 ajax 调用,然后服务器充当代理并向 bugzilla Web 服务(位于单独的域中)发送 POST 请求。

var obj={
    'method':'Bug.get',
    'params':{
        'id':bug_list
    },
    'id':bug_list
};
var message=$.toJSON(obj);

$.ajax({
    "contentType":"application/json",
    "data": message,
    "dataType": "json",
    "url": "bug_reply.cgi",
    "type": "post",
    error: function(d, ts, er){
        console.log("OH WOE! D: D: D: D: D: D: D: D: D:"+d+' '+ts+' '+er);
    },
    success: function(d, ts){
        console.log(d);
    }
});

计算机图形图像:

#! /usr/bin/perl

use strict;

use lib qw(.);
use CGI qw(:standard Vars);
use vars qw($cgi $template $vars);

use Bug;
use Bugzilla;
use Bugzilla::Search;
use JSON::XS;
use LWP::UserAgent;
use CGI qw(:standard);


# Include the Bugzilla CGI and general utility library.
require "CGI.pl";

my $ua = LWP::UserAgent->new;


my %form = Vars();
if($ENV{REQUEST_METHOD} eq "POST")
{
    my $URL='http://bugs1.eng.proofpoint.com/bugzilla-3.6.4/jsonrpc.cgi';

    my $q = new CGI;
    #my $query =
    my $data=$form{'POSTDATA'};

    my $req=HTTP::Request->new(POST=>$URL);
    $req->content_type('application/x-www-form-urlencoded');
    $req->content($data);

    my $ua = LWP::UserAgent->new;
    my $res = $ua->request($req);

    if ($res->is_success) {
        printf "Content-Type: %s\n\n", $res->header('Content-Type');
        print $res->content;
    } 
    else {
        printf "Content-Type: text/plain\n\n";
        print "Error: " . $res->status_line . "\n";
    }

    print $cgi->header(-type => 'text/xml');
    print $res->decoded_content;
}

I am using jsonrpc to access bugzilla webservice's bug.get feature, but it is returning:

Error: 403
Forbidden Content-Type: text/xml
No data.

I make an ajax call to my server, which then acts as a proxy and sends off a POST request to the bugzilla webservice (which is on a separate domain).

var obj={
    'method':'Bug.get',
    'params':{
        'id':bug_list
    },
    'id':bug_list
};
var message=$.toJSON(obj);

$.ajax({
    "contentType":"application/json",
    "data": message,
    "dataType": "json",
    "url": "bug_reply.cgi",
    "type": "post",
    error: function(d, ts, er){
        console.log("OH WOE! D: D: D: D: D: D: D: D: D:"+d+' '+ts+' '+er);
    },
    success: function(d, ts){
        console.log(d);
    }
});

cgi:

#! /usr/bin/perl

use strict;

use lib qw(.);
use CGI qw(:standard Vars);
use vars qw($cgi $template $vars);

use Bug;
use Bugzilla;
use Bugzilla::Search;
use JSON::XS;
use LWP::UserAgent;
use CGI qw(:standard);


# Include the Bugzilla CGI and general utility library.
require "CGI.pl";

my $ua = LWP::UserAgent->new;


my %form = Vars();
if($ENV{REQUEST_METHOD} eq "POST")
{
    my $URL='http://bugs1.eng.proofpoint.com/bugzilla-3.6.4/jsonrpc.cgi';

    my $q = new CGI;
    #my $query =
    my $data=$form{'POSTDATA'};

    my $req=HTTP::Request->new(POST=>$URL);
    $req->content_type('application/x-www-form-urlencoded');
    $req->content($data);

    my $ua = LWP::UserAgent->new;
    my $res = $ua->request($req);

    if ($res->is_success) {
        printf "Content-Type: %s\n\n", $res->header('Content-Type');
        print $res->content;
    } 
    else {
        printf "Content-Type: text/plain\n\n";
        print "Error: " . $res->status_line . "\n";
    }

    print $cgi->header(-type => 'text/xml');
    print $res->decoded_content;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

看海 2024-10-28 02:45:30

我只是用curl代替,它起作用了。

I just used curl instead and it worked.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文