Skip to main content
 
 
 
IN THIS SECTION
4 posts
asamei
Last seen: 11/07/2018 - 21:30
Joined: 10/25/2018 - 21:08
Internal Server Error (HTTP 500)

Hi,

I am trying to download some data for a list of around 5000 patents from PatentsView API through patentsview package in R. However, after downloading information of 570 patents, I am getting the following error:

   

    "Error in xheader_er_or_status(resp) : Internal Server Error (HTTP 500)."

 

Could you please help me to solve this problem?

Here are my code if it helps:

 

library(patentsview)
###(patentsview::fieldsdf)
setwd("/Users/alisamei/Dropbox (IESE)/Ali-Remote folder/FDA Patent Product Database")
##patents_field <- read.csv("patentsviewfields_patents.csv")
patent_no <- read.csv("FDA_patent_product_2014_2018.csv")

##creating empty dataframe to feed in final data
patents <- data.frame(matrix(NA_character_, nrow = 4858, ncol = 31))
inventors <- data.frame(matrix(NA_character_, nrow = 4858, ncol = 24))
assignees <- data.frame(matrix(NA_character_, nrow = 4858, ncol = 31))
IPCs <- data.frame(matrix(NA_character_, nrow = 4858, ncol = 16))
cited_patents <- data.frame(matrix(NA_character_, nrow = 4858, ncol = 7))
citedby_patents <- data.frame(matrix(NA_character_, nrow = 4858, ncol = 6))
uspcs <- data.frame(matrix(NA_character_, nrow = 4858, ncol = 11))
cpcs <- data.frame(matrix(NA_character_, nrow = 4858, ncol = 15))
nbers <- data.frame(matrix(NA_character_, nrow = 4858, ncol = 10))
gov_interests <- data.frame(matrix(NA_character_, nrow = 4858, ncol = 8))

## just running the search_pv query for the first patent on the list to fill in the first row of the data frame
result <- search_pv(query = qry_funs$contains(patent_id=as.character(patent_no[2,])),
                    fields = get_fields(endpoint = "patents", groups = c("patents","assignees", "inventors", "cpcs","nbers","uspcs", "gov_interests","ipcs","coinventors","cited_patents","citedby_patents")))
output <- unnest_pv_data(data=result$data, pk="patent_id")
output_patents <- output$patents
output_inventors <- output$inventors
output_assignees <- output$patents
output_ipcs <- output$IPCs
output_cited_patents <- output$cited_patents
output_citedby_patents <- output$citedby_patents
output_uspcs <- output$uspcs
output_cpcs <- output$cpcs
output_nbers <- output$nbers
output_gov_interests <- output$gov_interests
patents<- output_patents
inventors<- output_inventors
assignees<- output_assignees
ipcs <- output_ipcs
cited_patents <- output_cited_patents
citedby_patents <- output_citedby_patents
uspcs <- output_uspcs
cpcs <- output_cpcs
nbers <- output_nbers
gov_interests <- output_gov_interests

##looping over the whole list
for (i in 571:nrow(patent_no)){
  result <- search_pv(query = qry_funs$contains(patent_id=as.character(patent_no[i,])),
    fields = get_fields(endpoint = "patents", groups = c("patents","assignees", "inventors", "cpcs","nbers","uspcs", "gov_interests","ipcs","coinventors","cited_patents","citedby_patents")))
  if (is.null(dim(result$data$patents))==TRUE) {
    patents[i,1]<- as.character(patent_no[i,1])
    patents[i,2:31]<- "."
    inventors[i,1]<- as.character(patent_no$patent_id[i])
    inventors[i,2:24] <- "."
    assignees[i,1]<- as.character(patent_no$patent_id[i])
    assignees[i,2:31]<- "."
    ipcs[i,1]<- as.character(patent_no$patent_id[i])
    ipcs[i,2:16] <- "."
    cited_patents[i,1]<- as.character(patent_no$patent_id[i])
    cited_patents[i,2:7] <- "."
    citedby_patents[i,1]<- as.character(patent_no$patent_id[i])
    citedby_patents[i,2:6] <- "."
    uspcs[i,1]<- as.character(patent_no$patent_id[i])
    uspcs[i,2:11] <- "."
    cpcs[i,1]<- as.character(patent_no$patent_id[i])
    cpcs[i,2:15] <- "."
    nbers[i,1]<- as.character(patent_no$patent_id[i])
    nbers[i,2:10] <- "."
    gov_interests[i,1]<- as.character(patent_no$patent_id[i])
    gov_interests[i,2:8] <- "."
  } else {
  output <- unnest_pv_data(data=result$data, pk="patent_id")
  output_patents <- output$patents
  output_inventors <- output$inventors
  output_assignees <- output$patents
  output_cited_patents <- output$cited_patents
  output_citedby_patents <- output$citedby_patents
  output_uspcs <- output$uspcs
  output_cpcs <- output$cpcs
  output_nbers <- output$nbers
  output_gov_interests <- output$gov_interests
  patents[i,]<- output_patents
  inventors[i,]<- output_inventors
  assignees[i,]<- output_assignees
  ipcs[i,] <- output_ipcs
  cited_patents[i,] <- output_cited_patents
  citedby_patents[i,] <- output_citedby_patents
  uspcs[i,] <- output_uspcs
  cpcs[i,] <- output_cpcs
  nbers[i,] <- output_nbers
  gov_interests[i,] <- output_gov_interests
  }
}

Russ
Last seen: 12/06/2024 - 09:12
Joined: 11/14/2017 - 22:15
Things to try

I'd try using qry_funs$eq instead of qry_funs$contains which might match more than one patent.  I'd also look at what the 570th and 571st patent numbers are in your input file.  You could then try making a query in a browser for those patent numbers to see if an error is thrown http://www.patentsview.org/api/patents/query?q={"patent_number":"your_number_here"}

There is an open issue with the locations endpoint where the number of groups present causes a 500 to be thrown.  

Russ

asamei
Last seen: 11/07/2018 - 21:30
Joined: 10/25/2018 - 21:08
Thanks a lot Russ. It seems…

Thanks a lot Russ. It seems the problem is solved following your lead!

PVTeam
Role: moderator
Last seen: 11/29/2024 - 15:02
Joined: 10/17/2017 - 10:47
Re: INTERNAL SERVER ERROR (HTTP 500)

Hi,

Asamei – We are glad you were able to resolve your issue.

Russ – Thank you for providing input! We will look into the open issue and follow-up when it has been resolved.

Thank you,

PVTeam