3
回答
用java的http请求创建一个redmine的项目报401问题
华为云实践训练营,热门技术免费实践!>>>   

Server returned HTTP response code: 401 for URL: http://localhost/redmine/projects.xml,谁知道怎么解决啊

发送的报文:<name>我了割草</name><identifier>test</identifier><enabled_module_names>time_tracking</enabled_module_names><enabled_module_names>issue_tracking</enabled_module_names>

用的是post请求

HttpURLConnection servletConnection = (HttpURLConnection) uploadServlet
                   .openConnection();
            servletConnection.setRequestProperty("Content-Type", "application/xml");

servletConnection.setRequestMethod("POST");
            servletConnection.setDoOutput(true);
            servletConnection.setDoInput(true);
            servletConnection.setAllowUserInteraction(true);
            // 开启流,写入XML数据
            out = new PrintWriter(servletConnection.getOutputStream());
            // 发送请求参数
            out.print(sendXml);
            LOG.info("发送的报文:"+sendXml);
            // flush输出流的缓冲
            out.flush();

<无标签>
举报
顶部