Response is empty when a GET request is made for a firestore collection with underscore in name

37 views Asked by At

I am not sure if it is an issue with httr package or with firestore. Following is my function for GET request:

library(httr)
get_data_from_firestore <- function(db_endpoint, auth_token) {
  r <- httr::GET(
    sprintf("https://firestore.googleapis.com/v1beta1/%s", db_endpoint),
    httr::add_headers(
      "Content-Type" = "application/json",
      "Authorization" = paste("Bearer", auth_token)
    )
  )
  return(r)
}

When I do the GET request for my_collection, I get empty response:

PROJECT_NAME <- "PROJECT-ID"
accessTokenu <- "TOKEN"
get_data_from_firestore(db_endpoint = paste0("projects/", PROJECT_NAME, 
                                             "/databases/(default)/documents/my_collection"), 
                        auth_token = accessTokenu)

Response [https://firestore.googleapis.com/v1beta1/projects/PROJECT-ID/databases/(default)/documents/my_collection]
  Date: 2024-03-14 16:34
  Status: 200
  Content-Type: application/json; charset=UTF-8
  Size: 3 B
{}

I do have documents in this collection! If I make the same request for a different collection that has no underscore in it, it returns me all the documents. Moreover, if I make a request with a particular document path in my_collection, I get the document data.

Is the use of underscore causing any issues in the curl command? How can I check that?

0

There are 0 answers