httpurlconnection get 500错误而不是401错误

2izufjch  于 2021-07-13  发布在  Java
关注(0)|答案(0)|浏览(274)

当我从postman调用api时,我从postman得到401(接受的代码),但我从spring项目得到500。
我的httpurlconnection配置是:
httpurlconnection con=(httpurlconnection)url.openconnection();

con.setRequestMethod("GET");
        con.setRequestProperty("Authorization", "Bearer " + token_);
        con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
        con.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
        con.addRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:221.0) Gecko/20100101 Firefox/31.0"); 
        con.setDoOutput(true);
        con.setDoInput(true);
        int responseCode = con.getResponseCode();

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题