bugzilla webservice做bug.get需要身份验证吗?(bugzilla webservice does bug.get require authentication?)

编程入门 行业动态 更新时间:2024-10-24 18:27:43
bugzilla webservice做bug.get需要身份验证吗?(bugzilla webservice does bug.get require authentication?)

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

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

我对我的服务器进行ajax调用,然后该服务器充当代理并向bugzilla webservice(位于单独的域)发送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); } });

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; }

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; }

最满意答案

我只是使用curl而且它有效。

I just used curl instead and it worked.

更多推荐

本文发布于:2023-04-27 21:03:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1329072.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:身份验证   webservice   bugzilla   bug   authentication

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!