title: cannot transform type bson.Raw to a BSON Document: length read exceeds number of bytes available
body: <p>Trying to add some json data from an API to a database but get this error when trying</p>
  
  <p><code>cannot transform type bson.Raw to a BSON Document: length read exceeds number of bytes available. length=259839 bytes=1919951</code></p>
  
  <p>I know the json is well below mongodb limit of 16mb, ive even tried importing just some small data from <a href="http://api.open-notify.org/astros.json" rel="nofollow noreferrer">this api</a> but get the same error. I was able to import just a test struct to see it was working but my api data doesnt seem to be going through. Is there some type of conversion i need to do with my api data? Here is my golang code</p>
  
  <pre><code>func main(i int) {
  
      url := "http://api.open-notify.org/astros.json"
  
      resp, err := http.Get(url)
      if err != nil {
          log.Fatalln(err)
      }
  
      body, err := ioutil.ReadAll(resp.Body)
      if err != nil {
          log.Fatalln(err)
      }
      // _ = body
      log.Println(string(body))
  
  
      clientOptions := options.Client().ApplyURI("mongodb+srv://username:password@cluster0-slmxe.mongodb.net/dbtest?retryWrites=true&amp;w=majority")
  
      // Connect to MongoDB
      client, err := mongo.Connect(context.TODO(), clientOptions)
  
      if err != nil {
          log.Fatal(err)
      }
  
      err = client.Ping(context.TODO(), nil)
  
      if err != nil {
          log.Fatal(err)
      }
  
      fmt.Println("Connected to database")
  
      collection := client.Database("dbtest").Collection("test")
  
      insertResult, err := collection.InsertOne(context.TODO(), body)
      if err != nil {
          log.Fatal(err)
      }
      fmt.Println("Inserted", insertResult.InsertedID)
  
      }
  </code></pre>