2014-10-11 6 views
1

웹 브라우저에서 http://musicbrainz.org/ws/2/artist/?query=artist:Sun+Ra을 방문하면 기대하는 응답을 얻을 수 있습니다.MusicBrainz 웹 서비스에서 httr가 실패하는 이유는 무엇입니까?

하지만

require(httr) 
GET('http://musicbrainz.org/ws/2/artist/?query=artist:Sun+Ra') -> sun.ra 
content(sun.ra) 
>>> NULL 

응답 본문은 sun.ra 상태 200 얻었다하더라도, 비어있는 경우 : httr는 "벌거 벗은"XML 응답에 문제가 있습니까

Response [http://musicbrainz.org/ws/2/artist/?query=artist:Sun+Ra] 
Date: 2014-10-11 17:26 
Status: 200 
Content-type: application/json; charset=utf-8 
    <EMPTY BODY> 

를?

이 XML 파일에는 관련된 스타일 정보가 없습니다.


답변

1

그것은 아니다 (사실 ... 난 그냥 계속 질문을 게시하고 경우 다른 사람이 자신을 대답하는 것, 답을 알아 낸 후 같은 문제가있는 것 같아요) XML 문제 MusicBrainz는 API 키가 필요하지 않지만 서비스에 자신을 명시해야합니다. 이것은 쉽게 RCurl로 볼 수 있습니다 :

require(RCurl) 
getURL('http://musicbrainz.org/ws/2/artist/?query=artist:Sun+Ra' 
[1] "<?xml version=\"1.0\" encoding=\"UTF-8\"?><error><text>Your requests are 
    being throttled by MusicBrainz because the application you are using 
    has not identified itself. 
Please update your application, and see http://musicbrainz.org/doc/XML_Web_Service/Rate_Limiting for more information.</text><text>For usage, please see: http://musicbrainz.org/development/mmd</text></error>" 
+0

HTTR이 수정과 더 나은 기본 출력 제공 : https://github.com/hadley/httr/commit/5c640efa89b73673154bc5ca00f68f477918aa71 (초기 요청의 콘텐츠 형식에주의) – hadley

+0

감사합니다 @ hadley, 나는 그 반응이 json이지만 그것을 만들기 위해 무엇을 해야할지 몰랐다. – isomorphismes

+0

오, 알겠습니다. 'httr'은 응답을'xml'보다는'json'으로 해석하고있었습니다. 빠른 수정을 가져 주셔서 감사합니다! – isomorphismes