title: R httr - $ operator error after ~100 GET requests
body: <p>I'm playing around with the httr package at home, trying to pull back information about my Spotify library using their API. I'm running into a peculiar problem on which I couldn't find any help online, and I was hoping someone more well versed could point me towards a solution.</p>
  
  <p>I have a list of my Spotify library songs' URI's, and all I'm trying to do is to retrieve the artists' names.</p>
  
  <pre><code> getArtistName &lt;- function(x){
      GET(paste('https://api.spotify.com/v1/tracks/', x, "/", sep="")) %&gt;% 
      content %&gt;%
      .$artists %&gt;%
      .[[1]] %&gt;%
      .$name
   }
  
   songs.df$Artist &lt;- sapply(songs.df$ID, getArtistName)
  </code></pre>
  
  <p>However, after some time I get the error</p>
  
  <pre><code>Error in .$artists : $ operator is invalid for atomic vectors
  </code></pre>
  
  <p>Which is odd, because if I use GET individually, it works fine, i.e.</p>
  
  <pre><code> GET(paste('https://api.spotify.com/v1/tracks/', songs.df$ID[1], "/", sep="")) %&gt;% 
      content %&gt;%
      .$artists %&gt;%
      .[[1]] %&gt;%
      .$name
  
  [1] "Viktor Vaughn"
  </code></pre>
  
  <p>Then I decided to use a for loop to apply the function to each ID individually, in case there was a faulty one, </p>
  
  <pre><code>for(i in 1:nrow(songs.df)){
    songs.df$Artist[i] &lt;- GET(paste('https://api.spotify.com/v1/tracks/', songs.df$ID[i], "/", sep="")) %&gt;% 
      content %&gt;%
      .$artists %&gt;%
      .[[1]] %&gt;%
      .$name
  }
  </code></pre>
  
  <p>but after the 100th iteration, I get the same $ operator error. </p>
  
  <pre><code>Error in .$artists : $ operator is invalid for atomic vectors
  
  &gt; i
  [1] 101
  </code></pre>
  
  <p>But when I tried to get the artist name for <code>songs.df$ID[101]</code> outside of the loop, it worked!</p>
  
  <p>So I started the loop from 101 again, and it pulls back the 101th ID fine, but stops after another 50-100 loops. This keeps going on and on, I'm getting the $ operator error every 50-100 attempt, at which point I start the loop again from that <code>i</code>, and then it stops again, etc.</p>
  
  <p>Has anyone encountered anything similar before? Is there a limitation on the number of <code>GET</code>s you can do at once?</p>
  
  <p>Thanks for your help in advance!</p>