@@ -180,42 +180,53 @@ get_cid <-
180180 }
181181 if (verbose ) webchem_message(" query" , query , appendLF = FALSE )
182182 if (from %in% structure_search ) {
183- qurl <- paste(" https://pubchem.ncbi.nlm.nih.gov/rest/pug" ,
184- domain ,
185- from ,
186- URLencode(as.character(query ), reserved = TRUE ),
187- " json" ,
188- sep = " /" )
183+ qurl <- paste(
184+ " https://pubchem.ncbi.nlm.nih.gov/rest/pug" ,
185+ domain ,
186+ from ,
187+ URLencode(as.character(query ), reserved = TRUE ),
188+ " json" ,
189+ sep = " /"
190+ )
191+ } else if (from == " smiles" ) {
192+ qurl <- paste0(
193+ " https://pubchem.ncbi.nlm.nih.gov/rest/pug/" ,
194+ domain , " /" ,
195+ from , " /" ,
196+ " cids/JSON?smiles=" ,
197+ URLencode(as.character(query ), reserved = TRUE )
198+ )
199+ } else if (from == " inchi" ) {
200+ qurl <- paste(
201+ " https://pubchem.ncbi.nlm.nih.gov/rest/pug" ,
202+ domain ,
203+ from ,
204+ " cids" ,
205+ " json" ,
206+ sep = " /"
207+ )
189208 } else {
190- if (from == " smiles" ) {
191- qurl <- paste0(" https://pubchem.ncbi.nlm.nih.gov/rest/pug/" ,
192- domain , " /" ,
193- from , " /" ,
194- " cids/JSON?smiles=" ,
195- URLencode(as.character(query ), reserved = TRUE ))
196- } else {
197- qurl <- paste(" https://pubchem.ncbi.nlm.nih.gov/rest/pug" ,
198- domain ,
199- from ,
200- URLencode(as.character(query ), reserved = TRUE ),
201- " cids" ,
202- " json" ,
203- sep = " /" )
204- }
209+ qurl <- paste(
210+ " https://pubchem.ncbi.nlm.nih.gov/rest/pug" ,
211+ domain ,
212+ from ,
213+ URLencode(as.character(query ), reserved = TRUE ),
214+ " cids" ,
215+ " json" ,
216+ sep = " /"
217+ )
205218 }
206219 if (! is.null(arg )) qurl <- paste0(qurl , " ?" , arg )
207220 webchem_sleep(type = ' API' )
208221 if (from == " inchi" ) {
209- qurl <- paste(" https://pubchem.ncbi.nlm.nih.gov/rest/pug" ,
210- domain , from , " cids" , " json" , sep = " /" )
211222 res <- try(httr :: RETRY(" POST" ,
212223 qurl ,
213224 user_agent(webchem_url()),
214225 body = paste0(" inchi=" , query ),
215226 terminate_on = 404 ,
216227 quiet = TRUE ), silent = TRUE )
217228 } else {
218- res <- try(httr :: RETRY(" POST " ,
229+ res <- try(httr :: RETRY(" GET " ,
219230 qurl ,
220231 user_agent(webchem_url()),
221232 terminate_on = c(202 , 404 ),
@@ -233,7 +244,7 @@ get_cid <-
233244 " listkey" , listkey , " cids" , " json" , sep = " /" )
234245 while (res $ status_code == 202 ) {
235246 webchem_sleep(time = 5 )
236- res <- try(httr :: RETRY(" POST " ,
247+ res <- try(httr :: RETRY(" GET " ,
237248 qurl ,
238249 user_agent(webchem_url()),
239250 terminate_on = 404 ,
0 commit comments