The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Dissemination and Capacity Strengthening » Application Programming Interface (API)  » API query relocated (API error)
API query relocated [message #30418] Tue, 26 November 2024 12:40 Go to next message
DHSuser_NY is currently offline  DHSuser_NY
Messages: 9
Registered: November 2019
Member
Hi all,


I wrote the following code in 2023 to import percent of pregnant women who slept under a treated tent by subgroups for all surveys from 2006 to 2022. I've successfully run it as recent as May 2024.

import delimited using ///
" http://api.dhsprogram.com/rest/dhs/data?surveyYearStart=2006 &surveyYearEnd=2022&breakdown=all&indicatorIds=M L_NETW_W_ITN,&returnfields=surveyId,DHS_CountryCode,Coun tryName,SurveyYear,SurveyYearLabel,SurveyType,FieldworkStart ,FieldworkEnd,indicator,IndicatorID,value,IndicatorData,Char acteristicLabel,CharacteristicCategory,Footnotes,ByVariableI d,shortname&f=csv&apiKey=GUTTMA-130129,perpage==5000", clear


Today when I run the code, the attached error occurs, indicating that the file has permanently been redirected but no new location given. Admittedly I was a new API user and after such a long time of not having to work with it, I really don't know how to debug this. Any assistance would be greatly appreciated.

Thanks much

Re: API query relocated [message #30477 is a reply to message #30418] Thu, 05 December 2024 13:49 Go to previous message
Trevor-DHS is currently offline  Trevor-DHS
Messages: 805
Registered: January 2013
Senior Member
I was able to run the code without much trouble, but with a couple of minor corrections:
1) Make sure there are no spaces in the URL (the userforum adds spaces sometimes - just remove them). Remove the space before HTTP, and remove each of the other spaces that are shown.
2) The perpage setting should have only 1 equals sign.
I'm attaching a file with the corrected version.
  • Attachment: APIcall.txt
    (Size: 0.42KB, Downloaded 6 times)
Previous Topic: Relative standard errors and design effects across surveys
Goto Forum:
  


Current Time: Sun Dec 8 05:06:41 Coordinated Universal Time 2024