【发布时间】:2023-02-14 23:25:52
【问题描述】:
datasets_uids <- c("b0ozQvcc7nP","D9CrlbX7KBV")
服务器 <- c("url1","url2")
for (i in 1:length(datasets_uids)) {
for(j in 1:length(servers)){
assign(paste("postOrgUnitsToDataset",j,sep="_"),httr::POST(paste0(servers[j],"dhis/api/dataSets/",datasets_uids[i],"/organisationUnits"), body=httr::upload_file("file.json"),
httr::verbose(),
httr::authenticate("username","password", type = "basic"),
httr::content_type("application/json"),
httr::progress("up"),
httr::set_config(httr::config(ssl_verifypeer = 0L))
))
}
}
我希望将所有四个回复保存如下
postOrgUnitsToDataset_1=response1
postOrgUnitsToDataset_2=response2
postOrgUnitsToDataset_3=response3
postOrgUnitsToDataset_4=response4
但是响应被覆盖并保存在以下两个响应中
postOrgUnitsToDataset_1=response3
postOrgUnitsToDataset_2=response4
那么我如何修改上面的代码以将所有回复保存在postOrgUnitsToDataset_1,postOrgUnitsToDataset_2,postOrgUnitsToDataset_3,postOrgUnitsToDataset_4
【问题讨论】:
标签: r