스포티 파이 API에 대한 405 오류 제공 :컬 작동하지만 Jsoup 내가 명령 줄에서 아래 전화 사용하여 스포티 파이 웹 API에 대한 액세스 토큰을 얻기 위해이 URL을 곱슬 곱슬 수 있어요
curl -H "Authorization: Basic <Base64 client_id:client_secret>" -d grant_type=client_credentials https://accounts.spotify.com/api/token
을 그리고 나는 응답을 얻을 the api_token.
Map<String, String> data = Maps.newHashMap();
data.put("grant_type", "client_credentials");
String clientCred =
new String(
Base64.encodeBase64((CLIENT_ID + ":" + CLIENT_SECRET).getBytes()));
String url = "https://accounts.spotify.com/api/token";
Document doc = Jsoup.connect(URIUtil.encodeQuery(url))
.header("Accept-Language", "en")
.header("Authorization", "Basic " + clientCred)
.header("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8")
.data(data)
.ignoreHttpErrors(true)
.header("Accept",
"text/html,application/xhtml+xml,application/xml;q=0.9"
+ ",*/*;q=0.8")
.get();
내가 요청 매개 변수를 설정에서 뭔가 잘못하고 있습니까 : 나는 Jsoup을 통해 자바에서이 작업을 수행 할 때, 나는 405 오류가? 같은 HttpURLConnection도 동일한 요청 매개 변수를 사용하여 시도했지만 동일한 405 오류로도 실패합니다.
리퍼러와 사용자 에이전트를 추가해보세요. – alkis
나는 그것을 시도해도 작동하지 않았다. 위의 헤더를 제거하고 추가하려고했습니다. – Sap