gpt4 book ai didi

java - 如何使用curl调用dropbox api?

转载 作者:太空宇宙 更新时间:2023-11-04 09:16:25 26 4
gpt4 key购买 nike

我有一个 Dropbox Controller

@RestController
@RequestMapping("dropbox")
public class DropboxController {
private static final Logger logger = LoggerFactory.getLogger(DropboxController.class);

@Autowired
DropboxService dropboxService;

@Autowired
DbxClientV2 dropboxClient;

@GetMapping("/list")
public List<Map<String, Object>> index(@RequestParam(value = "target", required = false, defaultValue = "") String target) throws Exception {
return dropboxService.getFileList(target);
}

Springboot 应用程序

@SpringBootApplication
@ComponentScan(basePackages = {
"aic.filestorage2.controller",
"aic.filestorage2.service"
})

@Import({WebConfig.class})
public class DropboxExampleApplication {

public static void main(String[] args) {
SpringApplication.run(DropboxExampleApplication.class, args);
}
@Bean("dropboxClient")
public DbxClientV2 dropboxClient() throws DbxException {
String ACCESS_TOKEN = "ACCESS_TOKEN";
DbxRequestConfig config = new DbxRequestConfig("dropbox/java-tutorial");
DbxClientV2 client = new DbxClientV2(config, ACCESS_TOKEN);
return client;


}
}

使用curl时如何调用它?当我尝试使用 dropbox/listlocalhost:8080/dropbox/list 时,它显示“无法解析主机”或第二个“status:404”

最佳答案

您对 RequestMapping 的定义似乎与我使用的不同。

试试这个:

@RestController
public class DropboxController {
private static final Logger logger = LoggerFactory.getLogger(DropboxController.class);

@Autowired
DropboxService dropboxService;

@Autowired
DbxClientV2 dropboxClient;

@RequestMapping(value="/dropbox/list", method = RequestMethod.GET)
public List<Map<String, Object>> index(@RequestParam(value = "target", required = false, defaultValue = "") String target) throws Exception {
return dropboxService.getFileList(target);
}

你的curl命令看起来像这样:

curl -v http://localhost:8080/dropbox/list?target=myfile

关于java - 如何使用curl调用dropbox api?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58922704/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com