python code sample: import requests
url = “https://wonder.cdc.gov/datarequest/D158”
response = request.post(url, data{“request_xml”: xml_request, “accept_datause_restrictions”: “true”})
if response.status_code == 200: data = response.text else: print(“something went wrong”)
library(httr)
# in the response from the manual use of the wonder data request, it seems like it is dataset D158. Other sources say it is D76. Both result in a status code of 500.
url<-"https://wonder.cdc.gov/controller/datarequest/D158"
xml_request <-paste(
readLines("https://raw.githubusercontent.com/dianaplunkett/608/main/Underlying%20Cause%20of%20Death-req2.xml",
warn = FALSE),
collapse = "\n")
response <- POST(url,
body = list(request_xml = xml_request, accept_datause_restrictions = "true"),
encode = "form")
if (response$status_code == 200) {
data <- content(response, "text")
} else {
print("Something went wrong")
}
## [1] "Something went wrong"
Response Code is 500.