V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
9fan
V2EX  ›  程序员

钉钉服务端 api 设置代理

  •  
  •   9fan · 3 小时 8 分钟前 · 181 次点击
    public static com.aliyun.dingtalkstorage_1_0.models.GetFileUploadInfoResponseBody getFileUploadInfo() {
    GetFileUploadInfoResponse rsp;
    try {
    RuntimeOptions runtimeOptions = new RuntimeOptions();
    // 设置代理
    // String url = "http://192.168.0.15:9028/api";
    // runtimeOptions.setHttpProxy(url);
    rsp = storageClient1.getFileUploadInfoWithOptions(
    getSpaceId(),
    new GetFileUploadInfoRequest()
    .setUnionId(getUser(null).getUnionid())
    .setProtocol("HEADER_SIGNATURE")
    .setMultipart(false),
    new GetFileUploadInfoHeaders().setXAcsDingtalkAccessToken(getAccessToken()),
    runtimeOptions
    );
    } catch (Exception e) {
    log.error("钉盘-获取文件上传信息 异常: ", e);
    throw new ServiceException("钉盘-获取文件上传信息 异常: " + e.getMessage());
    }
    com.aliyun.dingtalkstorage_1_0.models.GetFileUploadInfoResponseBody fileInfo = rsp.getBody();
    return fileInfo;
    } 这里一设置代理就错误:com.aliyun.tea.TeaUnretryableException: Unexpected response code for CONNECT: 400
    at com.aliyun.teaopenapi.Client.execute(Client.java:1183) 其中 192.168.0.15 中的 nginx 配置:server{
    listen 9028;
    server_name localhost;
    location /api {
    proxy_pass https://api.dingtalk.com/;
    proxy_connect_timeout 60;
    proxy_read_timeout 60;
    proxy_send_timeout 60;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host 'api.dingtalk.com';
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto https;
    }
    location / {
    proxy_pass https://oapi.dingtalk.com/;
    proxy_connect_timeout 60;
    proxy_read_timeout 60;
    proxy_send_timeout 60;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host 'oapi.dingtalk.com';
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto https;
    }
    } 下面是 nginx access.log -->> 192.168.0.69 - - [19/Dec/2024:10:24:15 +0800] "CONNECT api.dingtalk.com:443 HTTP/1.1" 400 157 "-" "-" 现在是想知道怎么在 RuntimeOptions 这里面设置正确的代理,官方文档翻了又翻,确实没有相关介绍,求助各位大佬给予帮助,立正感谢
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5406 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 19ms · UTC 05:59 · PVG 13:59 · LAX 21:59 · JFK 00:59
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.