mingjerli / IMFData

An R package for IMF data api
Other
48 stars 18 forks source link

Possible update in IMF API #11

Open jopsamp opened 7 years ago

jopsamp commented 7 years ago

Hello,

I was using the package normally until today when I received the following erro message:

Error: lexical error: invalid char in json text. <html xmlns="http://www.w3.org/ (right here) ------^

After checking the API query in the browser, I noticed that the query generated by the package was receiving the following error message in the browser:

API : http://dataservices.imf.org/REST/SDMX_JSON.svc/CompactData/IFS/Q+A.BR+US.NGDP_R_PT?startPeriod=1990-01-01&endPeriod=2017-12-31

Error: The requested URL does not comply with standards and has been rejected. Please contact your admin with the support ID 9176104504529288535

Changing the separation between the variable code and the startPeriod from ? to + solved the problem. I believe this is due to a change in IMF's API.

New API: http://dataservices.imf.org/REST/SDMX_JSON.svc/CompactData/IFS/Q+A.BR+US.NGDP_R_PT+startPeriod=1990-01-01&endPeriod=2017-12-31

Any thoughts?

ghost commented 7 years ago

I have exactly the same problem

mingjerli commented 7 years ago

Both API calls work right now. I cannot replicate the error at this time. Still investigating the problem. However, the second API call with +startPeriod does not filter the data based on date range. I can see the starting data point is 1950-Q1.

ghost commented 7 years ago

The problem persists in my case. This is my call and the error that appears:


fdi_asst        <- c("BFDA_BP6_USD","BFDAD_BP6_USD","BFDAE_BP6_USD")
databaseID <- "BOP"
startdate   <- "1980-01-01"
enddate     <- "2016-12-31"
checkquery <- FALSE
FDI_ASSETS <- as.data.frame(CompactDataMethod(databaseID, list(CL_FREA = "Q", CL_AREA_BOP = "", CL_INDICATOR_BOP= fdi_asst), startdate, enddate, checkquery))
 Show Traceback

 Rerun with Debug
 Error: lexical error: invalid char in json text.
                                       <html xmlns="http://www.w3.org/
                     (right here) ------^ 
``

The call used to work perfectlly last time I run it. 
rasdk commented 7 years ago

This problem seems to have come up again, and again changing the separation between the variable code and the startPeriod from ? to + solves the problem.

Problem arose in the last weeks time or so.

I would like to add though, that I only get it for some variable specifications. Any thoughts as to why?

EDIT: This problem seems to coincide with monthly or quarterly updates at the IMF. Wait a few days and try your code again.