簡體   English   中英

通過代理服務器的DocuSign REST API

[英]DocuSign REST API via Proxy Server

我有Docusign Rest API演練中使用的以下代碼。 由於我是代理人,因此我添加了代理人信息。

public HttpURLConnection initializeRequest(String url, String method, 
   String body, String httpAuthHeader) {
        try {

            Proxy proxy = new Proxy(Proxy.Type.HTTP, 
                new InetSocketAddress("proxyServer address", proxyPort));

            conn = (HttpURLConnection) new URL(url).openConnection(proxy);
            conn.setRequestMethod(method);
            conn.setRequestProperty("X-DocuSign-Authentication",
                httpAuthHeader);
            conn.setRequestProperty("Accept", "application/json");
            if (method.equalsIgnoreCase("POST")) {
                conn.setRequestProperty("Content-Type", 
                    "multipart/form-data; boundary=BOUNDARY");
                conn.setDoOutput(true);
            } else {
                conn.setRequestProperty("Content-Type", "application/json");
            }
            return conn;
        } catch (Exception e) {
            throw new RuntimeException(e); // simple exception handling
                                           // please review it
        }
    }

這運行良好,但是最近代理需要身份驗證,我的休息呼叫出現未經授權的401錯誤。

我確實更改了代碼以在其中包含身份驗證器,但是仍然遇到相同的問題,除此以外我還有什么建議可以嘗試?

public HttpURLConnection initializeRequest(String url, String method, String body, String httpAuthHeader) {
        try {

            Proxy proxy = new Proxy(Proxy.Type.HTTP, 
                new InetSocketAddress("proxyServerAdress", intPort));

            Authenticator authenticator = new Authenticator() {

                public PasswordAuthentication getPasswordAuthentication() {
                    return (new PasswordAuthentication("username",
                        "password".toCharArray()));
                }
            };
            Authenticator.setDefault(authenticator);


            conn = (HttpURLConnection) new URL(url).openConnection(proxy);

            conn.setRequestMethod(method);
            conn.setRequestProperty("X-DocuSign-Authentication",
                httpAuthHeader);
            conn.setRequestProperty("Accept", "application/json");
            if (method.equalsIgnoreCase("POST")) {
                conn.setRequestProperty("Content-Type", 
                    "multipart/form-data; boundary=BOUNDARY");
                conn.setDoOutput(true);
            } else {
                conn.setRequestProperty("Content-Type", "application/json");
            }
            return conn;
        } catch (Exception e) {
            throw new RuntimeException(e); // simple exception handling
                                           // please review it
        }
    }

使用requestb.in查看通過代理服務器發送到DocuSign的內容。

您使用代理的基本身份驗證可能已發送到平台不希望的DocuSign。

向您的代理人投訴。 他們破壞了您正在運行的應用程序,這應該是他們要解決的問題...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM